app/Http/Controllers/Admin/BidsController.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(Tender $tender, Bid $bid, Request $request)
    {
        $this->validate($request, [
            'company_name' => 'bail|required|string',
            'company_reg_no' => 'bail|required|string',
            'ntn_number' => 'bail|required|string|unique:bids,ntn_number,'.$bid->id,
            'contact_person' => 'bail|required|string',
            'email' => 'bail|required|email',
            'contact_no' => 'bail|required|string',
            'upload_file.*' => 'bail|required|file|mimes:pdf,doc,ppt,xls,docx,pptx,xlsx|max:8192' 
        ]);
        $userId = \Auth::user()->id;
        if(request()->hasFile('upload_file')){
            $sizeInBytes = request()->file('upload_file')->getSize();
            $filenamewithextension = request()->file('upload_file')->getClientOriginalName();
            $filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);
            $filename = rand(000,999).'_'.uniqid();
            $extension = request()->file('upload_file')->getClientOriginalExtension();
            $filenametostore = $filename.'.'.$extension;
            $path = Storage::disk('local')->put($filenametostore, fopen(request()->file('upload_file'), 'r+'));
        }
        $bid->update([
            'company_name' => Crypt::encryptString($request->company_name),
            'ntn_number' => $request->ntn_number,
            'experience' => Crypt::encryptString($request->experience),
            'amount' =>     $request->amount,
            'contact_person' => Crypt::encryptString($request->contact_person),
            'email' => Crypt::encryptString($request->email),
            'contact_no' => Crypt::encryptString($request->contact_no),
            'upload_file' => $filenametostore,
            'extension' => $extension,
            'user_id' => $userId
        ]);
        Toastr::success('Data Updated Successfully', 'Success', ['positionClass' => 'toast-top-right']);
        return redirect()->route('tenders.bids.index',$tender->id);
    }
public function update ( Tender $ tender , Bid $ bid , Request $ request ) { $ this -> validate ( $ request , [ 'company_name' => 'bail|required|string' , 'company_reg_no' => 'bail|required|string' , 'ntn_number' => 'bail|required|string|unique:bids,ntn_number,' . $ bid -> id , 'contact_person' => 'bail|required|string' , 'email' => 'bail|required|email' , 'contact_no' => 'bail|required|string' , 'upload_file.*' => 'bail|required|file|mimes:pdf,doc,ppt,xls,docx,pptx,xlsx|max:8192' ] ) ; $ userId = \ Auth :: user ( ) -> id ; if ( request ( ) -> hasFile ( 'upload_file' ) ) { $ sizeInBytes = request ( ) -> file ( 'upload_file' ) -> getSize ( ) ; $ filenamewithextension = request ( ) -> file ( 'upload_file' ) -> getClientOriginalName ( ) ; $ filename = pathinfo ( $ filenamewithextension , PATHINFO_FILENAME ) ; $ filename = rand ( 000 , 999 ) . '_' . uniqid ( ) ; $ extension = request ( ) -> file ( 'upload_file' ) -> getClientOriginalExtension ( ) ; $ filenametostore = $ filename . '.' . $ extension ; $ path = Storage :: disk ( 'local' ) -> put ( $ filenametostore , fopen ( request ( ) -> file ( 'upload_file' ) , 'r+' ) ) ; } $ bid -> update ( [ 'company_name' => Crypt :: encryptString ( $ request -> company_name ) , 'ntn_number' => $ request -> ntn_number , 'experience' => Crypt :: encryptString ( $ request -> experience ) , 'amount' => $ request -> amount , 'contact_person' => Crypt :: encryptString ( $ request -> contact_person ) , 'email' => Crypt :: encryptString ( $ request -> email ) , 'contact_no' => Crypt :: encryptString ( $ request -> contact_no ) , 'upload_file' => $ filenametostore , 'extension' => $ extension , 'user_id' => $ userId ] ) ; Toastr :: success ( 'Data Updated Successfully' , 'Success' , [ 'positionClass' => 'toast-top-right' ] ) ; return redirect ( ) -> route ( 'tenders.bids.index' , $ tender -> id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//8mb // 'file.*' => 'required|file|max:5000|mimes:pdf,docx,doc', //dd($request->toArray()); //get filename without extension //get file extension //filename to store //dd($filenametostore);