本文整理汇总了PHP中Recipe::find_by_chef_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Recipe::find_by_chef_id方法的具体用法?PHP Recipe::find_by_chef_id怎么用?PHP Recipe::find_by_chef_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Recipe
的用法示例。
在下文中一共展示了Recipe::find_by_chef_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public static function show($id)
{
$chef = Chef::find($id);
if ($chef) {
$recipes = Recipe::find_by_chef_id($chef->id);
$comments = Comment::find_by_chef_id($chef->id);
$recipes_for_comments = array();
foreach ($comments as $comment) {
$recipes_for_comments[$comment->recipe_id] = Recipe::find($comment->recipe_id);
}
View::make('chef/show.html', array('chef' => $chef, 'recipes' => $recipes, 'comments' => $comments, 'recipes_for_comments' => $recipes_for_comments));
} else {
Redirect::to('/', array('error' => 'Käyttäjää ei löytynyt'));
}
}
示例2: destroy
public function destroy()
{
// Poista käyttäjän reseptit
$chefs_recipes = Recipe::find_by_chef_id($this->id);
foreach ($chefs_recipes as $recipe) {
/* @var $recipe Recipe */
$recipe->destroy();
}
// Poista käyttäjän kommentit
$chefs_comments = Comment::find_by_chef_id($this->id);
foreach ($chefs_comments as $comment) {
/* @var $comment Comment */
$comment->delete();
}
$query = DB::connection()->prepare("DELETE FROM Chef WHERE id = :id");
$query->execute(array('id' => $this->id));
}