Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.