forked from acearo/base-laravel
28 lines
678 B
PHP
28 lines
678 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Recipe;
|
|
use App\RecipeIngredient;
|
|
use App\User;
|
|
|
|
class RecipeController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
//Pass all users
|
|
$recipes = Recipe::with('user')->get();
|
|
return view('recipes.index')->with('recipes', $recipes);
|
|
}
|
|
public function show($id)
|
|
{
|
|
$recipe=Recipe::with('user')->with('ingredients')->findOrFail($id);
|
|
return $ingredients;
|
|
}
|
|
public function edit($id){
|
|
$recipe=Recipe::with('user')->with('ingredients')->findOrFail($id);
|
|
$ingredients=RecipeIngredient::get()->sortby('name')->pluck('name')->unique();
|
|
return $ingredients;
|
|
}
|
|
}
|