* - added some test * - cr fix * wip * wip * Update resources/js/Shared/MainMenu.vue Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
		
			
				
	
	
		
			34 lines
		
	
	
		
			642 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			642 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace Toby\Domain\Actions;
 | 
						|
 | 
						|
use Toby\Eloquent\Models\User;
 | 
						|
use Toby\Eloquent\Models\YearPeriod;
 | 
						|
 | 
						|
class CreateUserAction
 | 
						|
{
 | 
						|
    public function execute(array $data): User
 | 
						|
    {
 | 
						|
        $user = new User($data);
 | 
						|
 | 
						|
        $user->save();
 | 
						|
 | 
						|
        $this->createVacationLimitsFor($user);
 | 
						|
 | 
						|
        return $user;
 | 
						|
    }
 | 
						|
 | 
						|
    protected function createVacationLimitsFor(User $user): void
 | 
						|
    {
 | 
						|
        $yearPeriods = YearPeriod::all();
 | 
						|
 | 
						|
        foreach ($yearPeriods as $yearPeriod) {
 | 
						|
            $user->vacationLimits()->create([
 | 
						|
                "year_period_id" => $yearPeriod->id,
 | 
						|
            ]);
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |