app/Http/Controllers/AllCookBooksController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  Request  $request
     * @return Response
     */
Store a newly created resource in storage.
@param  Request  $request
@return Response
Store a newly created resource in storage . @param Request $request @return Response
public function store(Request $request, $id)
    {
        $rules = array(
            'title' => 'required|string|min:2|max:30',
            'description' => 'max:100'
        );        
        $this->validate($request, $rules);
        $cook = Cookbook::create([
            'title' => $request->title,
            'user_id' => Auth::User()->id,
            'description' => $request->description
        ]);
        RecipeInCookBook::create([
            'recipe_id' => $id,
            'cookbook_id' => $cook->id
        ]);
        return redirect()->action('RecipeController@show', $id);
    }
public function store ( Request $ request , $ id ) { $ rules = array ( 'title' => 'required|string|min:2|max:30' , 'description' => 'max:100' ) ; $ this -> validate ( $ request , $ rules ) ; $ cook = Cookbook :: create ( [ 'title' => $ request -> title , 'user_id' => Auth :: User ( ) -> id , 'description' => $ request -> description ] ) ; RecipeInCookBook :: create ( [ 'recipe_id' => $ id , 'cookbook_id' => $ cook -> id ] ) ; return redirect ( ) -> action ( 'RecipeController@show' , $ id ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .