Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $title = Input::get('title');
     $cookbook = new Cookbook(['title' => $title, 'slug' => Str::slug($title)]);
     $cookbook->user_id = Auth::user()->id;
     $this->validate($request, ['title' => 'required|max:255']);
     if ($cookbook->save()) {
         return redirect()->route('cookbooks.index')->with('status', 'Kookboek aangemaakt.');
     } else {
         abort(500);
     }
 }
Esempio n. 2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param Request $request
  * @return User
  */
 public function create(Request $request)
 {
     $user = User::create($request->only('name', 'email', 'password'));
     $title = "{$user->name} kookboek";
     Cookbook::create(['title' => $title, 'slug' => str_slug($title), 'user_id' => $user->id]);
     return $user;
 }
Esempio n. 3
0
 public function allCookbooks(View $view)
 {
     $view->with('cookbooks', Cookbook::select('id', 'title', 'slug')->orderBy('id', 'desc')->get());
 }