app/Http/Controllers/BankController.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(Request $request)
    {
        $attributes = array(
            "name" => "required|min:3|unique:banks,name",
            "email" => "required|email|unique:banks,email",
        );
        $validator = Validator::make($request->all(), $attributes);
        if ($validator->fails()) {
            return $validator->errors();
        } else {
            $bank = new bank();
            $bank->name = $request->name;
            $bank->email = $request->email;
            $bank->password = bcrypt('password');
            $newBank = $bank->save();
            if ($newBank) {
                $response = [
                    'bank' => $bank,
                ];
                return response($response, 201);
            } else {
                return response([
                    'message' => ['Sorry , something went wrong']
                ], 404);
            }
        }
    }
public function store ( Request $ request ) { $ attributes = array ( " name " => " required|min:3|unique:banks,name " , " email " => " required|email|unique:banks,email " , ) ; $ validator = Validator :: make ( $ request -> all ( ) , $ attributes ) ; if ( $ validator -> fails ( ) ) { return $ validator -> errors ( ) ; } else { $ bank = new bank ( ) ; $ bank -> name = $ request -> name ; $ bank -> email = $ request -> email ; $ bank -> password = bcrypt ( 'password' ) ; $ newBank = $ bank -> save ( ) ; if ( $ newBank ) { $ response = [ 'bank' => $ bank , ] ; return response ( $ response , 201 ) ; } else { return response ( [ 'message' => [ 'Sorry , something went wrong' ] ] , 404 ) ; } } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//