app/Http/Controllers/Admin/EmployeeController.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(StoreEmployeeRequest $request)
    {
        $requestedData = collect($request->validated());
        $user = User::create($requestedData->only('name', 'email', 'password')->merge(['email_verified_at', now()])->toArray());
        $user->assignRole($request->role);
        $user->companyProfile()->attach(Auth::user()->company());
        $employeeProfile = $requestedData->except('name', 'email', 'password')->toArray();
        $user->employeeProfile()->create($employeeProfile);
        return redirect()->route('admin.employees.index')->withSuccess('Employee created successfully');
    }
public function store ( StoreEmployeeRequest $ request ) { $ requestedData = collect ( $ request -> validated ( ) ) ; $ user = User :: create ( $ requestedData -> only ( 'name' , 'email' , 'password' ) -> merge ( [ 'email_verified_at' , now ( ) ] ) -> toArray ( ) ) ; $ user -> assignRole ( $ request -> role ) ; $ user -> companyProfile ( ) -> attach ( Auth :: user ( ) -> company ( ) ) ; $ employeeProfile = $ requestedData -> except ( 'name' , 'email' , 'password' ) -> toArray ( ) ; $ user -> employeeProfile ( ) -> create ( $ employeeProfile ) ; return redirect ( ) -> route ( 'admin.employees.index' ) -> withSuccess ( 'Employee created successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//