app/Http/Controllers/Dashboard/Videos.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Video $video)
    {
        $requestArray = request()->validate([
            'name'          => ['required' , 'max:191'],
            'des'           => ['required' , 'min:10'],
            'meta_keywords' => ['max:191'],
            'meta_des'      => ['max:191'],
            'youtube'       => ['required' ,'min:10' , 'url'],
            'published'     => ['required'],
            'image'         => ['nullable' , 'image'],
            'cat_id'        => ['required' ,'integer'],
            'skills'        => ['required'] , 
            'tags'          => ['required']
        ]);
        if(request()->hasFile('image')){
         $file = request()->file('image');
         $fileName = time().Str::random('10').'.'.$file->getClientOriginalExtension();
         $file->move( public_path('uploads') , $fileName ); 
         $requestArray['image'] =  $fileName ;
        }
        $video->update($requestArray);
        $video->skills()->sync( $requestArray['skills'] );
        $video->tags()->sync( $requestArray['tags'] );
        alert()->success('Video is Updated' , 'Done');
        return redirect()->route('videos.index');
    }
public function update ( Video $ video ) { $ requestArray = request ( ) -> validate ( [ 'name' => [ 'required' , 'max:191' ] , 'des' => [ 'required' , 'min:10' ] , 'meta_keywords' => [ 'max:191' ] , 'meta_des' => [ 'max:191' ] , 'youtube' => [ 'required' , 'min:10' , 'url' ] , 'published' => [ 'required' ] , 'image' => [ 'nullable' , 'image' ] , 'cat_id' => [ 'required' , 'integer' ] , 'skills' => [ 'required' ] , 'tags' => [ 'required' ] ] ) ; if ( request ( ) -> hasFile ( 'image' ) ) { $ file = request ( ) -> file ( 'image' ) ; $ fileName = time ( ) . Str :: random ( '10' ) . '.' . $ file -> getClientOriginalExtension ( ) ; $ file -> move ( public_path ( 'uploads' ) , $ fileName ) ; $ requestArray [ 'image' ] = $ fileName ; } $ video -> update ( $ requestArray ) ; $ video -> skills ( ) -> sync ( $ requestArray [ 'skills' ] ) ; $ video -> tags ( ) -> sync ( $ requestArray [ 'tags' ] ) ; alert ( ) -> success ( 'Video is Updated' , 'Done' ) ; return redirect ( ) -> route ( 'videos.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .