Created
September 18, 2014 19:54
-
-
Save ricardo-rossi/bdec62aff72c6bbbccbf to your computer and use it in GitHub Desktop.
This file contains 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 | |
class IngredientTypesController extends BaseController { | |
/** | |
* Ingredient Types Repository | |
* | |
* @var IngredientType | |
*/ | |
protected $type; | |
public function __construct(IngredientType $type) | |
{ | |
$this->type = $type; | |
} | |
/** | |
* Display a listing of the resource. | |
* | |
* @return Response | |
*/ | |
public function index() | |
{ | |
return $this->type->filterByAccount() | |
->orderBy('name')->get(); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @return Response | |
*/ | |
public function store() | |
{ | |
$type = new IngredientType(); | |
$type->name = Input::get('name'); | |
$type->setAccount(); | |
$type->save(); | |
return $type; | |
} | |
/** | |
* Display the specified resource. | |
* | |
* @param int $id | |
* @return Response | |
*/ | |
public function show($id) | |
{ | |
return $this->type->find($id); | |
} | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param int $id | |
* @return Response | |
*/ | |
public function update($id) | |
{ | |
return $this->type->find($id)->update(Input::all()); | |
} | |
/** | |
* Remove the specified resource from storage. | |
* | |
* @param int $id | |
* @return Response | |
*/ | |
public function destroy($id) | |
{ | |
$this->type->find($id)->delete(); | |
return Response::json(array( | |
'status' => 200, | |
), 200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment