本文整理匯總了PHP中app\Category::accessable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::accessable方法的具體用法?PHP Category::accessable怎麽用?PHP Category::accessable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Category
的用法示例。
在下文中一共展示了Category::accessable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, \App\Menu $menu, \App\Category $category)
{
$validation = \Validator::make($request->all(), ['name' => 'min:3']);
if ($validation->fails()) {
return response($validation->errors()->all(), 400);
}
if ($category->accessable($menu)) {
$category->update($request->all());
$category->savePhoto($request->file('photo'));
return $category;
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request, \App\Menu $menu, \App\Category $category)
{
$validation = \Validator::make($request->all(), ['name' => 'required|min:3', 'price' => 'required|integer|min:1']);
if ($validation->fails()) {
return response($validation->errors()->all(), 400);
}
if ($category->accessable($menu)) {
$food = new \App\Food($request->all());
$category->foods()->save($food);
$food->savePhotos(['photos' => $request->file('photos'), 'remove_photos' => $request->get('remove_photos'), 'main_photo' => $request->get('main_photo')]);
return $food;
}
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(\App\Category $category)
{
if ($category->accessable()) {
return $category->foods;
}
}
示例4: accessable
public function accessable(\App\Menu $menu, \App\Category $category)
{
return $category->id == $this->category_id && $category->accessable($menu);
}