#27 - separate fields for name and surname (#29)

* #27 - separate fields for name and surname

* #27 -cr fix
This commit is contained in:
Adrian Hopek
2022-01-24 12:40:56 +01:00
committed by GitHub
parent e147d24365
commit 6854c7a9f8
17 changed files with 127 additions and 48 deletions

View File

@@ -16,7 +16,8 @@ use Toby\Enums\EmploymentForm;
/**
* @property int $id
* @property string $name
* @property string $first_name
* @property string $last_name
* @property string $email
* @property string $avatar
* @property EmploymentForm $employment_form
@@ -29,13 +30,7 @@ class User extends Authenticatable
use Notifiable;
use SoftDeletes;
protected $fillable = [
"name",
"email",
"avatar",
"employment_form",
"employment_date",
];
protected $guarded = [];
protected $casts = [
"employment_form" => EmploymentForm::class,
@@ -58,7 +53,8 @@ class User extends Authenticatable
}
return $query
->where("name", "LIKE", "%{$text}%")
->where("first_name", "LIKE", "%{$text}%")
->orWhere("last_name", "LIKE", "%{$text}%")
->orWhere("email", "LIKE", "%{$text}%");
}
@@ -68,4 +64,9 @@ class User extends Authenticatable
$this->save();
}
public function getFullNameAttribute(): string
{
return "{$this->first_name} {$this->last_name}";
}
}