crud user

This commit is contained in:
2025-01-13 15:52:38 +03:00
commit aa478c1d8b
68 changed files with 14306 additions and 0 deletions

34
app/Models/User.php Normal file
View File

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $username
* @property string $email
* @property string $password_hash
* @property string $user_photo
* @property string $access_token
* @property string $access_token_expires_at
* @method static find($id)
*/
class User extends Model {
const DEFAULT_USER_ROLE = 1;
const ADMIN_USER_ROLE = 9;
protected $table = 'user';
protected $fillable = ['username', 'email', 'password_hash', 'user_photo', 'role', 'access_token', 'access_token_expires_at'];
protected array $dates = ['deleted at'];
public static function labels(): array
{
return [
'username' => 'Логин',
'email' => 'Email',
'user_photo' => 'Фото профиля',
'created_at' => 'Создан',
'updated_at' => 'Обновлен',
];
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class UserLaravel extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}