- small changes (#98)

* - 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>
This commit is contained in:
Adrian Hopek
2022-03-30 10:33:18 +02:00
committed by GitHub
parent ab16af1ca9
commit 08421b8a69
40 changed files with 323 additions and 286 deletions

View File

@@ -71,18 +71,6 @@ class User extends Authenticatable
return $this->hasMany(Vacation::class);
}
public function scopeSearch(Builder $query, ?string $text): Builder
{
if ($text === null) {
return $query;
}
return $query
->where("first_name", "ILIKE", $text)
->orWhere("last_name", "ILIKE", $text)
->orWhere("email", "ILIKE", $text);
}
public function getAvatar(): string
{
return $this->getAvatarGenerator()
@@ -108,6 +96,28 @@ class User extends Authenticatable
->exists();
}
public function scopeSearch(Builder $query, ?string $text): Builder
{
if ($text === null) {
return $query;
}
return $query
->where("first_name", "ILIKE", $text)
->orWhere("last_name", "ILIKE", $text)
->orWhere("email", "ILIKE", $text);
}
public function scopeWithVacationLimitIn(Builder $query, YearPeriod $yearPeriod): Builder
{
return $query->whereRelation(
"vacationlimits",
fn(Builder $query) => $query
->where("year_period_id", $yearPeriod->id)
->whereNotNull("days"),
);
}
protected function getAvatarName(): string
{
return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1);

View File

@@ -4,10 +4,12 @@ declare(strict_types=1);
namespace Toby\Eloquent\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
use Toby\Domain\VacationRequestStatesRetriever;
/**
* @property int $id
@@ -40,4 +42,12 @@ class Vacation extends Model
{
return $this->belongsTo(YearPeriod::class);
}
public function scopeApproved(Builder $query): Builder
{
return $query->whereRelation(
"vacationRequest",
fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()),
);
}
}