2025-04-25 09:33:28 +08:00
|
|
|
<?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;
|
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
2025-05-12 14:13:56 +08:00
|
|
|
use App\Traits\LogsModelActivity;
|
2025-05-12 16:56:31 +08:00
|
|
|
use Spatie\Activitylog\Traits\CausesActivity;
|
2025-05-14 17:08:42 +08:00
|
|
|
use Laravel\Sanctum\HasApiTokens;
|
2025-04-25 09:33:28 +08:00
|
|
|
|
2025-05-16 16:52:50 +08:00
|
|
|
/**
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="User",
|
|
|
|
* type="object",
|
|
|
|
* @OA\Property(property="id", type="integer", example=1),
|
|
|
|
* @OA\Property(property="name", type="string", example="John Doe"),
|
|
|
|
* @OA\Property(property="email", type="string", example="john@example.com"),
|
|
|
|
* @OA\Property(property="phone", type="string", example="0900000000"),
|
|
|
|
* @OA\Property(property="birthday", type="string", format="date-time", example="2025-05-11T16:00:00.000000Z"),
|
|
|
|
* @OA\Property(property="gender", ref="#/components/schemas/UserGender"),
|
|
|
|
* @OA\Property(property="status", ref="#/components/schemas/UserStatus"),
|
|
|
|
* )
|
|
|
|
*/
|
2025-04-25 09:33:28 +08:00
|
|
|
class User extends Authenticatable
|
|
|
|
{
|
|
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
2025-05-14 17:08:42 +08:00
|
|
|
use HasApiTokens, HasFactory, Notifiable, HasRoles, LogsModelActivity,CausesActivity;
|
2025-04-25 09:33:28 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var list<string>
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'email',
|
2025-04-29 14:18:07 +08:00
|
|
|
'phone',
|
|
|
|
'birthday',
|
|
|
|
'gender',
|
|
|
|
'status',
|
2025-04-25 09:33:28 +08:00
|
|
|
'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',
|
2025-05-05 11:22:40 +08:00
|
|
|
'birthday' => 'date',
|
|
|
|
'gender' => \App\Enums\UserGender::class,
|
|
|
|
'status' => \App\Enums\UserStatus::class,
|
2025-04-25 09:33:28 +08:00
|
|
|
];
|
|
|
|
}
|
2025-04-29 14:18:07 +08:00
|
|
|
|
|
|
|
public function songs() {
|
|
|
|
return $this->belongsToMany(Song::class, 'user_song')->withTimestamps();
|
|
|
|
}
|
2025-04-25 09:33:28 +08:00
|
|
|
}
|