app/Http/Controllers/Admin/PostController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(PostStoreRequest $request)
    {
        $post = Post::create($request->all());
        if ($request->file('file')){
            $path = Storage::disk('public')->put('image', $request->file('file'));
            $post->fill(['file' => asset($path)])->save();
        }
        $post->tags()->attach($request->get('tags'));
        return redirect()->route('posts.edit', $post->id)
            ->with('info', 'Entrada creada con éxito');
    }
public function store ( PostStoreRequest $ request ) { $ post = Post :: create ( $ request -> all ( ) ) ; if ( $ request -> file ( 'file' ) ) { $ path = Storage :: disk ( 'public' ) -> put ( 'image' , $ request -> file ( 'file' ) ) ; $ post -> fill ( [ 'file' => asset ( $ path ) ] ) -> save ( ) ; } $ post -> tags ( ) -> attach ( $ request -> get ( 'tags' ) ) ; return redirect ( ) -> route ( 'posts.edit' , $ post -> id ) -> with ( 'info' , 'Entrada creada con éxito') ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Validar //Image //relacion con el TAG