app/Http/Controllers/Admin/staffController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(StaffValidator $request)
    {
        if ($request->hasFile('photo')) {
            $image = $request->file('photo');
            $photo = "photo-" . time() . '.' . $image->getClientOriginalExtension();
            $image->move('images/staff/', $photo);
            }
        if ($request->hasFile('resume')) {
                $image = $request->file('resume');
                $resumes = "resume-" . time() . '.' . $image->getClientOriginalExtension();
                $image->move('images/staff/', $resumes);
            }
        if ($request->hasFile('ctzn_front')) {
                    $image = $request->file('ctzn_front');
                    $ctzn_front = "citizenfront-" . time() . '.' . $image->getClientOriginalExtension();
                    $image->move('images/staff/', $ctzn_front);
                }
        if ($request->hasFile('ctzn_back')) {
                    $image = $request->file('ctzn_back');
                    $ctzn_back = "citizenback-" . time() . '.' . $image->getClientOriginalExtension();
                    $image->move('images/staff/', $ctzn_back);
                }
        if ($request->hasFile('appointment_letter')) {
                    $image = $request->file('appointment_letter');
                    $appointment_letter = "appointment-" . time() . '.' . $image->getClientOriginalExtension();
                    $image->move('images/staff/', $appointment_letter);
                }
        if ($request->hasFile('contract_agreement')) {
                    $image = $request->file('contract_agreement');
                    $contract_agreement = "contract-" . time() . '.' . $image->getClientOriginalExtension();
                    $image->move('images/staff/', $contract_agreement);
                }
            $staff = new Staff([
                'employee_id'=>$request->employee_id,
                'fname' => $request->fname,
                'lname' => $request->lname,
                'dob' => $request->dob,
                'email'   => $request->email,
                'mobileno' => $request->mobileno,
                'phoneno' => $request->phoneno,
                'department_id' => $request->department_id,
                'title_id' => $request->title_id,
                'level_id' => $request->level_id,
                'city' => $request->city,
                'panno' => $request->panno,
                'district' => $request->district,
                'permanent_address' => $request->permanent_address,
                'temporary_address' => $request->temporary_address,
                'joined_date' => $request->joined_date,
                'gender' => $request->gender
            ]);
            $staff->photo = $photo;
            $staff->resume = $resumes;
            $staff->ctzn_front = $ctzn_front;
            $staff->ctzn_back = $ctzn_back;
            $staff->appointment_letter = $appointment_letter;
            $staff->contract_agreement = $contract_agreement;
            $staff->save();
        return redirect()->route('staff.index')->with('success', 'Staff Created Successfully');
    }
public function store ( StaffValidator $ request ) { if ( $ request -> hasFile ( 'photo' ) ) { $ image = $ request -> file ( 'photo' ) ; $ photo = " photo- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ photo ) ; } if ( $ request -> hasFile ( 'resume' ) ) { $ image = $ request -> file ( 'resume' ) ; $ resumes = " resume- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ resumes ) ; } if ( $ request -> hasFile ( 'ctzn_front' ) ) { $ image = $ request -> file ( 'ctzn_front' ) ; $ ctzn_front = " citizenfront- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ ctzn_front ) ; } if ( $ request -> hasFile ( 'ctzn_back' ) ) { $ image = $ request -> file ( 'ctzn_back' ) ; $ ctzn_back = " citizenback- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ ctzn_back ) ; } if ( $ request -> hasFile ( 'appointment_letter' ) ) { $ image = $ request -> file ( 'appointment_letter' ) ; $ appointment_letter = " appointment- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ appointment_letter ) ; } if ( $ request -> hasFile ( 'contract_agreement' ) ) { $ image = $ request -> file ( 'contract_agreement' ) ; $ contract_agreement = " contract- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/staff/' , $ contract_agreement ) ; } $ staff = new Staff ( [ 'employee_id' => $ request -> employee_id , 'fname' => $ request -> fname , 'lname' => $ request -> lname , 'dob' => $ request -> dob , 'email' => $ request -> email , 'mobileno' => $ request -> mobileno , 'phoneno' => $ request -> phoneno , 'department_id' => $ request -> department_id , 'title_id' => $ request -> title_id , 'level_id' => $ request -> level_id , 'city' => $ request -> city , 'panno' => $ request -> panno , 'district' => $ request -> district , 'permanent_address' => $ request -> permanent_address , 'temporary_address' => $ request -> temporary_address , 'joined_date' => $ request -> joined_date , 'gender' => $ request -> gender ] ) ; $ staff -> photo = $ photo ; $ staff -> resume = $ resumes ; $ staff -> ctzn_front = $ ctzn_front ; $ staff -> ctzn_back = $ ctzn_back ; $ staff -> appointment_letter = $ appointment_letter ; $ staff -> contract_agreement = $ contract_agreement ; $ staff -> save ( ) ; return redirect ( ) -> route ( 'staff.index' ) -> with ( 'success' , 'Staff Created Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .