app/Http/Controllers/Admin/AlbumsController.php
/**
     * Store a newly created Album in storage.
     *
     * @param  \App\Http\Requests\StoreAlbumsRequest  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created Album in storage.
Store a newly created Album in storage .
public function store(StoreAlbumsRequest $request)
    {
        if (! Gate::allows('album_create')) {
            return abort(401);
        }
        $album = Album::create($request->all());
        foreach ($request->input('products', []) as $data) {
            $album->products()->create($data);
        }
        return redirect()->route('admin.albums.index');
    }
public function store ( StoreAlbumsRequest $ request ) { if ( ! Gate :: allows ( 'album_create' ) ) { return abort ( 401 ) ; } $ album = Album :: create ( $ request -> all ( ) ) ; foreach ( $ request -> input ( 'products' , [ ] ) as $ data ) { $ album -> products ( ) -> create ( $ data ) ; } return redirect ( ) -> route ( 'admin.albums.index' ) ; }
Store a newly created Album in storage.
Store a newly created Album in storage .