* - directory refactor * - readme.md update * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace Tests\Traits;
 | 
						|
 | 
						|
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
 | 
						|
use Illuminate\Support\Carbon;
 | 
						|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
 | 
						|
use Toby\Eloquent\Models\YearPeriod;
 | 
						|
 | 
						|
trait InteractsWithYearPeriods
 | 
						|
{
 | 
						|
    use InteractsWithSession;
 | 
						|
 | 
						|
    public function createYearPeriod(int $year): YearPeriod
 | 
						|
    {
 | 
						|
        /** @var YearPeriod $yearPeriod */
 | 
						|
        $yearPeriod = YearPeriod::factory()->createQuietly([
 | 
						|
            "year" => $year,
 | 
						|
        ]);
 | 
						|
 | 
						|
        return $yearPeriod;
 | 
						|
    }
 | 
						|
 | 
						|
    public function createCurrentYearPeriod(): YearPeriod
 | 
						|
    {
 | 
						|
        return $this->createYearPeriod(Carbon::now()->year);
 | 
						|
    }
 | 
						|
 | 
						|
    public function markYearPeriodAsSelected(YearPeriod $yearPeriod): void
 | 
						|
    {
 | 
						|
        $this->session([
 | 
						|
            YearPeriodRetriever::SESSION_KEY => $yearPeriod->id,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function clearSelectedYearPeriod(): void
 | 
						|
    {
 | 
						|
        $this->session([]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function cleanYearPeriods(): void
 | 
						|
    {
 | 
						|
        $this->clearSelectedYearPeriod();
 | 
						|
 | 
						|
        YearPeriod::query()->delete();
 | 
						|
    }
 | 
						|
}
 |