config/app/Http/Controllers/SupplierController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Supplier  $supplier
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Supplier $supplier)
    {
        $request->validate([
            'supplier_name'=>'required|min:3',
            'supplier_brand'=>'required',
            'phone'=>'required|min:11|max:15',
            'email'=>'required',
        ],[
        ]);
        $url_slug = Str::of($request->supplier_name)->slug('-');
        $data = [
            'supplier_name'=>$request->supplier_name,
            'supplier_brand'=>$request->supplier_brand,
            'address'=>$request->address,
            'phone'=>$request->phone,
            'email'=>$request->email,
            'supplier_slug'=>$url_slug,
            'updated_at'=>Carbon::now()->toDateTimeString(),
        ];
        if($request->hasFile('supplier_img')){
            $image = $request->file('supplier_img');
            $image_name = $url_slug.'('.$request->id.')'.time().'.'.$image->getClientOriginalExtension();
            Image::make($image)->resize(250,250)->save(base_path('public/uploads/suppliers/'.$image_name));
            $data['supplier_img'] = $image_name;
        }
        $update = Supplier::where('supplier_status',1)
                    ->where('id',$request->id)->update($data);
        if($update){
            Session::flash('update_success','Suppliers Information Updated Successfully !');
            return redirect('/admin/suppliers/view/'.$url_slug);
        }
        else{
            Session::flash('update_error','Something were wrong');
            return redirect('/admin/suppliers/view/'.$url_slug);
        }
    }
public function update ( Request $ request , Supplier $ supplier ) { $ request -> validate ( [ 'supplier_name' => 'required|min:3' , 'supplier_brand' => 'required' , 'phone' => 'required|min:11|max:15' , 'email' => 'required' , ] , [ ] ) ; $ url_slug = Str :: of ( $ request -> supplier_name ) -> slug ( '-' ) ; $ data = [ 'supplier_name' => $ request -> supplier_name , 'supplier_brand' => $ request -> supplier_brand , 'address' => $ request -> address , 'phone' => $ request -> phone , 'email' => $ request -> email , 'supplier_slug' => $ url_slug , 'updated_at' => Carbon :: now ( ) -> toDateTimeString ( ) , ] ; if ( $ request -> hasFile ( 'supplier_img' ) ) { $ image = $ request -> file ( 'supplier_img' ) ; $ image_name = $ url_slug . '(' . $ request -> id . ')' . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; Image :: make ( $ image ) -> resize ( 250 , 250 ) -> save ( base_path ( 'public/uploads/suppliers/' . $ image_name ) ) ; $ data [ 'supplier_img' ] = $ image_name ; } $ update = Supplier :: where ( 'supplier_status' , 1 ) -> where ( 'id' , $ request -> id ) -> update ( $ data ) ; if ( $ update ) { Session :: flash ( 'update_success' , 'Suppliers Information Updated Successfully !' ) ; return redirect ( '/admin/suppliers/view/' . $ url_slug ) ; } else { Session :: flash ( 'update_error' , 'Something were wrong' ) ; return redirect ( '/admin/suppliers/view/' . $ url_slug ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
// return $request->all(); //image file update