app/Http/Controllers/Admin/CompanyController.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, Company $company)
    {
        $company = Company::find($company->id);
        $checkEmail = Company::select('email')->where('id', $company->id)->first();
        if($checkEmail->email == $request->email){
            return redirect()->back()->with('error', 'Email already exist please try another!');
        }
        $logo = null;
        if($request->has('logo'))
        {
            $file = $request->file('logo');
            $filename = 'company-logo-' . time() . '.' . $file->getClientOriginalExtension();
            $file->storeAs('public', $filename);
            $logo = $filename;
        }
        $company->name = $request->name;
        $company->email = $request->email;
        $company->website = $request->website;
        $company->logo = $logo;
        if($company->save()){
            return redirect()->back()->with('success', 'Saved');
        }
    }
public function update ( Request $ request , Company $ company ) { $ company = Company :: find ( $ company -> id ) ; $ checkEmail = Company :: select ( 'email' ) -> where ( 'id' , $ company -> id ) -> first ( ) ; if ( $ checkEmail -> email == $ request -> email ) { return redirect ( ) -> back ( ) -> with ( 'error' , 'Email already exist please try another!' ) ; } $ logo = null ; if ( $ request -> has ( 'logo' ) ) { $ file = $ request -> file ( 'logo' ) ; $ filename = 'company-logo-' . time ( ) . '.' . $ file -> getClientOriginalExtension ( ) ; $ file -> storeAs ( 'public' , $ filename ) ; $ logo = $ filename ; } $ company -> name = $ request -> name ; $ company -> email = $ request -> email ; $ company -> website = $ request -> website ; $ company -> logo = $ logo ; if ( $ company -> save ( ) ) { return redirect ( ) -> back ( ) -> with ( 'success' , 'Saved' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//$company->name = $request->name;