app/Http/Controllers/retailerController.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(RegisterRetailerDataRequest $request)
    {
        $imagePath = "";
        $RecordUser = new User;
        $RecordUser->name = $request->get('name');
        $RecordUser->email = $request->get('email');
        $RecordUser->password = bcrypt($request->get('password'));
        $id = DB::table('users')->insertGetId(
            ['email' => $RecordUser->email, 'name' => $RecordUser->name, 'password' => $RecordUser->password, 'type' => 'r']
        );
        $Record = new Retailers;
        $Record->address = $request->get('address');
        $Record->contactNo = $request->get('contactNo');
        if ($file = $request->hasFile('retailerImage')) {
            $file = $request->file('retailerImage');
            $fileName = $file->getClientOriginalName();
            $destinationPath = public_path() . '/images';
            $file->move($destinationPath, $fileName);
            $imagePath = $fileName;
            $Record->avatarImage = $imagePath;
        }
        $Record->shopName = $request->get('shopName');
        $Record->user_id = $id;
        $Record->save();
        \Session::flash('flash_message', 'New Retailer registerd Successfully.'); 
        return redirect()->back();
    }
public function store ( RegisterRetailerDataRequest $ request ) { $ imagePath = " " ; $ RecordUser = new User ; $ RecordUser -> name = $ request -> get ( 'name' ) ; $ RecordUser -> email = $ request -> get ( 'email' ) ; $ RecordUser -> password = bcrypt ( $ request -> get ( 'password' ) ) ; $ id = DB :: table ( 'users' ) -> insertGetId ( [ 'email' => $ RecordUser -> email , 'name' => $ RecordUser -> name , 'password' => $ RecordUser -> password , 'type' => 'r' ] ) ; $ Record = new Retailers ; $ Record -> address = $ request -> get ( 'address' ) ; $ Record -> contactNo = $ request -> get ( 'contactNo' ) ; if ( $ file = $ request -> hasFile ( 'retailerImage' ) ) { $ file = $ request -> file ( 'retailerImage' ) ; $ fileName = $ file -> getClientOriginalName ( ) ; $ destinationPath = public_path ( ) . '/images' ; $ file -> move ( $ destinationPath , $ fileName ) ; $ imagePath = $ fileName ; $ Record -> avatarImage = $ imagePath ; } $ Record -> shopName = $ request -> get ( 'shopName' ) ; $ Record -> user_id = $ id ; $ Record -> save ( ) ; \ Session :: flash ( 'flash_message' , 'New Retailer registerd Successfully.' ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//<--FLASH MESSAGE