app/Http/Controllers/Admin/staffController.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(StaffValidator $request, $id)
    {
        $staff = Staff::findorfail($id);
        if ($request->hasFile('photo')) {
            $new_img = $request->file('photo');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/staff/',$name);
            $staff->photo = $name;    
        }else{
            $staff->photo = $photo;
        }
        if ($request->hasFile('resume')) {
            $new_resume = $request->file('resume');
            $staffresume = "resume-" . time() .'.'. $new_resume->getClientOriginalExtension();
            $new_resume->move('images/staff/',$staffresume);
            $staff->resume = $staffresume;    
        }else{
            $staff->resume = $resume;
        }
        if ($request->hasFile('ctzn_front')) {
            $new_ctzn_front = $request->file('ctzn_front');
            $staffctzn_front = "citizenfront-" . time() .'.'. $new_ctzn_front->getClientOriginalExtension();
            $new_ctzn_front->move('images/staff/',$staffctzn_front);
            $staff->ctzn_front = $staffctzn_front;    
        }else{
            $staff->ctzn_front = $ctzn_front;
        }
        if ($request->hasFile('ctzn_back')) {
            $new_ctzn_back = $request->file('ctzn_back');
            $staffctzn_back = "citizenback-" . time() .'.'. $new_ctzn_back->getClientOriginalExtension();
            $new_ctzn_back->move('images/staff/',$staffctzn_back);
            $staff->ctzn_back = $staffctzn_back;    
        }else{
            $staff->ctzn_back = $ctzn_back;
        }
        if ($request->hasFile('appointment_letter')) {
            $new_appointment_letter = $request->file('appointment_letter');
            $staffappointment_letter = "appointment-" . time() .'.'. $new_appointment_letter->getClientOriginalExtension();
            $new_appointment_letter->move('images/staff/',$staffappointment_letter);
            $staff->appointment_letter = $staffappointment_letter;    
        }else{
            $staff->appointment_letter = $appointment_letter;
        }
        if ($request->hasFile('contract_agreement')) {
            $new_contract_agreement = $request->file('contract_agreement');
            $staffcontract_agreement = "contract-" . time() .'.'. $new_contract_agreement->getClientOriginalExtension();
            $new_contract_agreement->move('images/staff/',$staffcontract_agreement);
            $staff->contract_agreement = $staffcontract_agreement;    
        }else{
            $staff->contract_agreement = $contract_agreement;
        }
       $staff->employee_id=$request->input('employee_id');
        $staff->fname = $request->input('fname');
        $staff->lname = $request->input('lname');
        $staff->dob = $request->input('dob');
        $staff->email = $request->input('email');
        $staff->mobileno = $request->input('mobileno');
        $staff->phoneno = $request->input('phoneno');
        $staff->department_id = $request->input('department_id');
        $staff->title_id = $request->input('title_id');
        $staff->level_id = $request->input('level_id');
        $staff->city = $request->input('city');
        $staff->panno = $request->input('panno');
        $staff->district = $request->input('district');
        $staff->permanent_address = $request->input('permanent_address');
        $staff->temporary_address = $request->input('temporary_address');
        $staff->joined_date = $request->input('joined_date');
        $staff->gender = $request->input('gender');
        $staff->save();
        return redirect()->route('staff.index')->with('success', 'Employee Updated Successfully');
    }
public function update ( StaffValidator $ request , $ id ) { $ staff = Staff :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'photo' ) ) { $ new_img = $ request -> file ( 'photo' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/staff/' , $ name ) ; $ staff -> photo = $ name ; } else { $ staff -> photo = $ photo ; } if ( $ request -> hasFile ( 'resume' ) ) { $ new_resume = $ request -> file ( 'resume' ) ; $ staffresume = " resume- " . time ( ) . '.' . $ new_resume -> getClientOriginalExtension ( ) ; $ new_resume -> move ( 'images/staff/' , $ staffresume ) ; $ staff -> resume = $ staffresume ; } else { $ staff -> resume = $ resume ; } if ( $ request -> hasFile ( 'ctzn_front' ) ) { $ new_ctzn_front = $ request -> file ( 'ctzn_front' ) ; $ staffctzn_front = " citizenfront- " . time ( ) . '.' . $ new_ctzn_front -> getClientOriginalExtension ( ) ; $ new_ctzn_front -> move ( 'images/staff/' , $ staffctzn_front ) ; $ staff -> ctzn_front = $ staffctzn_front ; } else { $ staff -> ctzn_front = $ ctzn_front ; } if ( $ request -> hasFile ( 'ctzn_back' ) ) { $ new_ctzn_back = $ request -> file ( 'ctzn_back' ) ; $ staffctzn_back = " citizenback- " . time ( ) . '.' . $ new_ctzn_back -> getClientOriginalExtension ( ) ; $ new_ctzn_back -> move ( 'images/staff/' , $ staffctzn_back ) ; $ staff -> ctzn_back = $ staffctzn_back ; } else { $ staff -> ctzn_back = $ ctzn_back ; } if ( $ request -> hasFile ( 'appointment_letter' ) ) { $ new_appointment_letter = $ request -> file ( 'appointment_letter' ) ; $ staffappointment_letter = " appointment- " . time ( ) . '.' . $ new_appointment_letter -> getClientOriginalExtension ( ) ; $ new_appointment_letter -> move ( 'images/staff/' , $ staffappointment_letter ) ; $ staff -> appointment_letter = $ staffappointment_letter ; } else { $ staff -> appointment_letter = $ appointment_letter ; } if ( $ request -> hasFile ( 'contract_agreement' ) ) { $ new_contract_agreement = $ request -> file ( 'contract_agreement' ) ; $ staffcontract_agreement = " contract- " . time ( ) . '.' . $ new_contract_agreement -> getClientOriginalExtension ( ) ; $ new_contract_agreement -> move ( 'images/staff/' , $ staffcontract_agreement ) ; $ staff -> contract_agreement = $ staffcontract_agreement ; } else { $ staff -> contract_agreement = $ contract_agreement ; } $ staff -> employee_id = $ request -> input ( 'employee_id' ) ; $ staff -> fname = $ request -> input ( 'fname' ) ; $ staff -> lname = $ request -> input ( 'lname' ) ; $ staff -> dob = $ request -> input ( 'dob' ) ; $ staff -> email = $ request -> input ( 'email' ) ; $ staff -> mobileno = $ request -> input ( 'mobileno' ) ; $ staff -> phoneno = $ request -> input ( 'phoneno' ) ; $ staff -> department_id = $ request -> input ( 'department_id' ) ; $ staff -> title_id = $ request -> input ( 'title_id' ) ; $ staff -> level_id = $ request -> input ( 'level_id' ) ; $ staff -> city = $ request -> input ( 'city' ) ; $ staff -> panno = $ request -> input ( 'panno' ) ; $ staff -> district = $ request -> input ( 'district' ) ; $ staff -> permanent_address = $ request -> input ( 'permanent_address' ) ; $ staff -> temporary_address = $ request -> input ( 'temporary_address' ) ; $ staff -> joined_date = $ request -> input ( 'joined_date' ) ; $ staff -> gender = $ request -> input ( 'gender' ) ; $ staff -> save ( ) ; return redirect ( ) -> route ( 'staff.index' ) -> with ( 'success' , 'Employee Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .