Eshop-Laravel/app/Http/Controllers/CategoriesController.php
2019-10-18 12:25:37 +03:00

64 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\CategoryRequest;
use App\Categorie;
use Session;
class CategoriesController extends MainController
{
public function index()
{
self::$data['categories'] = Categorie::all()->toArray();
return view('cms.categories' , self::$data);
}
public function create()
{
return view('forms.addCategory' , self::$data);
}
public function store(CategoryRequest $request)
{
Categorie::save_new($request);
return redirect('cms/categories');
}
public function show($id)
{
self::$data['item'] = Categorie::find_item($id);
return view('cms.delete-categories' , self::$data);
}
public function edit($id)
{
self::$data['categories'] = Categorie::find_item($id);
return view('cms.cms-edit-categories' , self::$data);
}
public function update(CategoryRequest $request, $id)
{
Categorie::update_item($request,$id);
return redirect('cms/categories');
}
public function destroy($id)
{
Categorie::destroy($id);
Session::flash('sm' , 'Categorie Deleted');
return redirect('cms/categories');
}
}