Merge remote-tracking branch 'origin/#4-users-crud' into #4-users-crud
# Conflicts: # app/Enums/FormOfEmployment.php # app/Models/User.php # resources/js/Pages/Users/Index.vue # routes/web.php
This commit is contained in:
@@ -11,14 +11,16 @@ class CreateUserCommand extends Command
|
||||
{
|
||||
protected $signature = "user:create
|
||||
{email : an email for the user}";
|
||||
protected $description = "Creates user";
|
||||
protected $description = "Creates a user";
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$email = $this->argument("email");
|
||||
|
||||
User::factory(["email" => $email])->create();
|
||||
User::factory([
|
||||
"email" => $email,
|
||||
])->create();
|
||||
|
||||
$this->info("User has been created");
|
||||
$this->info("The user has been created");
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,11 @@ enum FormOfEmployment: string
|
||||
{
|
||||
$cases = collect(FormOfEmployment::cases());
|
||||
|
||||
return $cases->map(fn(FormOfEmployment $enum) => [
|
||||
"label" => $enum->label(),
|
||||
"value" => $enum->value]
|
||||
return $cases->map(
|
||||
fn(FormOfEmployment $enum) => [
|
||||
"label" => $enum->label(),
|
||||
"value" => $enum->value,
|
||||
],
|
||||
)->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class UserController extends Controller
|
||||
{
|
||||
return inertia("Users/Edit", [
|
||||
"user" => new UserFormDataResource($user),
|
||||
"employmentForms" => FormOfEmployment::casesToSelect()
|
||||
"employmentForms" => FormOfEmployment::casesToSelect(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ use Toby\Enums\FormOfEmployment;
|
||||
* @property string $email
|
||||
* @property string $avatar
|
||||
* @property FormOfEmployment $employment_form
|
||||
* @property Carbon $empoyment_date
|
||||
* @property Carbon $employment_date
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@@ -26,8 +26,6 @@ class User extends Authenticatable
|
||||
use Notifiable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $perPage = 10;
|
||||
|
||||
protected $fillable = [
|
||||
"name",
|
||||
"email",
|
||||
@@ -47,7 +45,7 @@ class User extends Authenticatable
|
||||
|
||||
public function scopeSearch(Builder $query, ?string $text): Builder
|
||||
{
|
||||
if ($text == null) {
|
||||
if ($text === null) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@@ -6,13 +6,14 @@ namespace Toby\Observers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Toby\Models\User;
|
||||
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
|
||||
use Toby\Models\User;
|
||||
|
||||
class UserObserver
|
||||
{
|
||||
public function __construct(protected InitialAvatar $generator)
|
||||
{
|
||||
public function __construct(
|
||||
protected InitialAvatar $generator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function created(User $user): void
|
||||
@@ -38,7 +39,7 @@ class UserObserver
|
||||
{
|
||||
$path = "avatars/{$user->id}.svg";
|
||||
|
||||
Storage::put($path, $this->generator->rounded()->background($this->getRandomColor())->generateSvg($user->name));
|
||||
Storage::put($path, $this->generator->rounded()->background($this->getRandomColor())->color("#F4F8FD")->smooth()->generateSvg($user->name));
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
Reference in New Issue
Block a user