app/Http/Controllers/UsersController.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(UsersRequest $request)
    {
        $user = new User();
        $user->name = $request->name;
        $user->email  = $request->email;
         if(is_null($request->hospital_id)){
        $user->hospital_id = auth()->user()->hospital_id;
         }
         else{
           $user->hospital_id = $request->hospital_id; 
        }
        $user->password = Hash::make($request->password);
        $user->save();
        return response()->json(['content' => $user, 'state' => 200]);
    }
public function store ( UsersRequest $ request ) { $ user = new User ( ) ; $ user -> name = $ request -> name ; $ user -> email = $ request -> email ; if ( is_null ( $ request -> hospital_id ) ) { $ user -> hospital_id = auth ( ) -> user ( ) -> hospital_id ; } else { $ user -> hospital_id = $ request -> hospital_id ; } $ user -> password = Hash :: make ( $ request -> password ) ; $ user -> save ( ) ; return response ( ) -> json ( [ 'content' => $ user , 'state' => 200 ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dd($request->all());