app/Http/Controllers/FbookController.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(UpdateFbookRequest $request, Fbook $fbook)
    {
      if ($request->hasFile('image')) {
        $image=$request->image->store('freebooks');
      }else {
        $image=$fbook->image;
      }
      $fbook->update([
       'name'=>strip_tags($request->name),
       'writer_name'=>strip_tags($request->writer_name),
       'category_id'=>$request->category_id,
       'description'=>strip_tags($request->description),
       'image'=>$image,
       'user_id'=>auth()->user()->id
      ]);
      if(Session::has('locale')==='en')
   {
        session()->flash('success','You updateed the book successfully' );
   }else {
     session()->flash('success','لقد قمت بتحديث الكتاب بنجاح');
   }
      return redirect(route('fbooks.index'));
    }
public function update ( UpdateFbookRequest $ request , Fbook $ fbook ) { if ( $ request -> hasFile ( 'image' ) ) { $ image = $ request -> image -> store ( 'freebooks' ) ; } else { $ image = $ fbook -> image ; } $ fbook -> update ( [ 'name' => strip_tags ( $ request -> name ) , 'writer_name' => strip_tags ( $ request -> writer_name ) , 'category_id' => $ request -> category_id , 'description' => strip_tags ( $ request -> description ) , 'image' => $ image , 'user_id' => auth ( ) -> user ( ) -> id ] ) ; if ( Session :: has ( 'locale' ) === 'en' ) { session ( ) -> flash ( 'success' , 'You updateed the book successfully' ) ; } else { session ( ) -> flash ( 'success' , 'لقد قمت بتحديث الكتاب بنجاح'); } return redirect ( route ( 'fbooks.index' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .