app/Http/Controllers/Admin/EmployeeController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Company  $company
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Employee $employee)
    {
        $employee = Employee::find($employee->id);
        $checkEmail = Employee::select('email')->where('id', $employee->id)->first();
        if($checkEmail->email == $request->email){
            return redirect()->back()->with('error', 'Email already exist please try another!');
        }
        $employee->firstname = $request->firstname;
        $employee->lastname = $request->lastname;
        $employee->email = $request->email;
        $employee->company_id = $request->company;
        $employee->phone = $request->phone;
        if($employee->save()){
            return redirect()->back()->with('success', 'Saved');
        }
    }
public function update ( Request $ request , Employee $ employee ) { $ employee = Employee :: find ( $ employee -> id ) ; $ checkEmail = Employee :: select ( 'email' ) -> where ( 'id' , $ employee -> id ) -> first ( ) ; if ( $ checkEmail -> email == $ request -> email ) { return redirect ( ) -> back ( ) -> with ( 'error' , 'Email already exist please try another!' ) ; } $ employee -> firstname = $ request -> firstname ; $ employee -> lastname = $ request -> lastname ; $ employee -> email = $ request -> email ; $ employee -> company_id = $ request -> company ; $ employee -> phone = $ request -> phone ; if ( $ employee -> save ( ) ) { return redirect ( ) -> back ( ) -> with ( 'success' , 'Saved' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//$company->name = $request->name;