app/Http/Controllers/BusinessesController.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)
    {
       $validate = $request->validate([
            'Company' => 'required',
            'location' => 'required',
            'Manager' => 'required',
            'Phone' => 'required',
            'fax' => 'required',
            'website' => 'required',
            'user_id' => 'required'
        ]);
        if ($validate) {
            $newBus = new Business();
            $newBus->Company = $request->Company;
            $newBus->location = $request->location;
            $newBus->Manager = $request->Manager;
            $newBus->Phone = $request->Phone;
            $newBus->fax = $request->fax;
            $newBus->website = $request->website;
            $newBus->user_id = $request->user_id;
            $newBus-> save();
            return $newBus;
        }else
        {
            return response()->json([
                "error" => "the make sure all the fields are submitted"
            ]);
        }
    }
public function store ( Request $ request ) { $ validate = $ request -> validate ( [ 'Company' => 'required' , 'location' => 'required' , 'Manager' => 'required' , 'Phone' => 'required' , 'fax' => 'required' , 'website' => 'required' , 'user_id' => 'required' ] ) ; if ( $ validate ) { $ newBus = new Business ( ) ; $ newBus -> Company = $ request -> Company ; $ newBus -> location = $ request -> location ; $ newBus -> Manager = $ request -> Manager ; $ newBus -> Phone = $ request -> Phone ; $ newBus -> fax = $ request -> fax ; $ newBus -> website = $ request -> website ; $ newBus -> user_id = $ request -> user_id ; $ newBus -> save ( ) ; return $ newBus ; } else { return response ( ) -> json ( [ " error " => " the make sure all the fields are submitted " ] ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
# add the business