app/Http/Controllers/Admin/customerController.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(CustomerValidator $request)
    {
        if ($request->hasFile('image')) {
        $image = $request->file('image');
        $images = "image-" . time() . '.' . $image->getClientOriginalExtension();
        $image->move('images/customer/', $images);
        }
        if ($request->hasFile('frontcitizenshipimage')) {
            $image = $request->file('frontcitizenshipimage');
            $front = "citizenfront-" . time() . '.' . $image->getClientOriginalExtension();
            $image->move('images/customer/', $front);
            }
        if ($request->hasFile('backcitizenshipimage')) {
                $image = $request->file('backcitizenshipimage');
                $back = "citizenback-" . time() . '.' . $image->getClientOriginalExtension();
                $image->move('images/customer/', $back);
            }
        $customer = new Customer([
            'fname' => $request->fname,
            'lname' => $request->lname,
            'dob' => $request->dob,
            'email'   => $request->email,
            'mobile' => $request->mobile,
            'phone' => $request->phone,
            'city' => $request->city,
            'district' => $request->district,
            'permanent_address' => $request->permanent_address,
            'temporary_address' => $request->temporary_address,
            'customer_type' => $request->customer_type,
            'gender' => $request->gender
        ]);
        $customer->image = $images;
        $customer->frontcitizenshipimage = $front;
        $customer->backcitizenshipimage = $back;
        $customer->save();
        return redirect()->route('customer.index')->with('success', 'Customer Created successfully');
    }
public function store ( CustomerValidator $ request ) { if ( $ request -> hasFile ( 'image' ) ) { $ image = $ request -> file ( 'image' ) ; $ images = " image- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/customer/' , $ images ) ; } if ( $ request -> hasFile ( 'frontcitizenshipimage' ) ) { $ image = $ request -> file ( 'frontcitizenshipimage' ) ; $ front = " citizenfront- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/customer/' , $ front ) ; } if ( $ request -> hasFile ( 'backcitizenshipimage' ) ) { $ image = $ request -> file ( 'backcitizenshipimage' ) ; $ back = " citizenback- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/customer/' , $ back ) ; } $ customer = new Customer ( [ 'fname' => $ request -> fname , 'lname' => $ request -> lname , 'dob' => $ request -> dob , 'email' => $ request -> email , 'mobile' => $ request -> mobile , 'phone' => $ request -> phone , 'city' => $ request -> city , 'district' => $ request -> district , 'permanent_address' => $ request -> permanent_address , 'temporary_address' => $ request -> temporary_address , 'customer_type' => $ request -> customer_type , 'gender' => $ request -> gender ] ) ; $ customer -> image = $ images ; $ customer -> frontcitizenshipimage = $ front ; $ customer -> backcitizenshipimage = $ back ; $ customer -> save ( ) ; return redirect ( ) -> route ( 'customer.index' ) -> with ( 'success' , 'Customer Created successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .