Last active
September 16, 2019 05:34
-
-
Save aungwinthant/3bf18986ce8e4d917f2a5ad9c1072fc6 to your computer and use it in GitHub Desktop.
Controller for category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Repositories\CategoryRepositoryInterface; | |
use Illuminate\Http\Request; | |
class CategoryController extends Controller | |
{ | |
protected $category; | |
public function __construct(CategoryRepositoryInterface $categoryRepo) | |
{ | |
$this->category = $categoryRepo; | |
} | |
/** | |
* Display a listing of the resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index(CategoryRepositoryInterface $categoryRepo) | |
{ | |
// | |
$categories = $this->category->list(); | |
return view('category.index',compact('categories')); | |
} | |
/** | |
* Show the form for creating a new resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function create() | |
{ | |
// | |
return view('category.create'); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
$validate = $this->validate($request,[ | |
"name" =>'required' | |
]); | |
$this->category->save($validate); | |
return redirect(route('category.index')); | |
} | |
/** | |
* Display the specified resource. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function show($id) | |
{ | |
// | |
} | |
/** | |
* Show the form for editing the specified resource. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function edit($id) | |
{ | |
// | |
} | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function update(Request $request, $id) | |
{ | |
// | |
} | |
/** | |
* Remove the specified resource from storage. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function destroy($id) | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment