app/Http/Controllers/BankController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\bank  $bank
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, bank $bank)
    {
          $bank= bank::find($request->id);
        if ($bank) {
            $attributes = array(
                "name" => "required|min:3|unique:banks,name,{$bank->id}",
                "email" => "required|email|unique:banks,email,{$company->id}",
               "email" => "required|min:3|unique:banks,email,{$bank->id}",
            );
            $validator = Validator::make($request->all(), $attributes);
            if ($validator->fails()) {
                return $validator->errors();
            } else {
                $bank->name = $request->name;
                $bank->email = $request->email;
                 $bank->password = $bank->password;
                $bank->save();
                if ($bank) {
                    $response = [
                        'message' => 'bank Updated',
                        'bank' => $bank
                    ];
                    return response($response, 201);
                } else {
                    return response([
                        'message' => 'These operation has failed'
                    ], 404);
                }
            }
        } else {
            return response([
                'message' => 'No bank Found'
            ], 404);
        }
    }
public function update ( Request $ request , bank $ bank ) { $ bank = bank :: find ( $ request -> id ) ; if ( $ bank ) { $ attributes = array ( " name " => " required|min:3|unique:banks,name, { $ bank -> id } " , " email " => " required|min:3|unique:banks,email, { $ bank -> id } " , ) ; $ validator = Validator :: make ( $ request -> all ( ) , $ attributes ) ; if ( $ validator -> fails ( ) ) { return $ validator -> errors ( ) ; } else { $ bank -> name = $ request -> name ; $ bank -> email = $ request -> email ; $ bank -> save ( ) ; if ( $ bank ) { $ response = [ 'message' => 'bank Updated' , 'bank' => $ bank ] ; return response ( $ response , 201 ) ; } else { return response ( [ 'message' => 'These operation has failed' ] , 404 ) ; } } } else { return response ( [ 'message' => 'No bank Found' ] , 404 ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
// // "email" => "required|email|unique:banks,email,{$company->id}", // $bank->password = $bank->password;