Skip to content

Instantly share code, notes, and snippets.

@ricardo-rossi
Created September 18, 2014 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardo-rossi/bdec62aff72c6bbbccbf to your computer and use it in GitHub Desktop.
Save ricardo-rossi/bdec62aff72c6bbbccbf to your computer and use it in GitHub Desktop.
<?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