diff --git a/app/Models/User.php b/app/Models/User.php index 749c7b7..a967f84 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -6,43 +6,45 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { - /** @use HasFactory<\Database\Factories\UserFactory> */ - use HasFactory, Notifiable; + use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * - * @var list + * @var array */ + // protected $fillable = [ + // 'name', + // 'email', + // 'password', + // ]; protected $fillable = [ - 'name', - 'email', - 'password', + 'login', ]; + /** * The attributes that should be hidden for serialization. * - * @var list + * @var array */ - protected $hidden = [ - 'password', - 'remember_token', - ]; + // protected $hidden = [ + // 'password', + // 'remember_token', + // ]; + protected $hidden = []; /** - * Get the attributes that should be cast. + * The attributes that should be cast. * - * @return array + * @var array */ - protected function casts(): array - { - return [ - 'email_verified_at' => 'datetime', - 'password' => 'hashed', - ]; - } + protected $casts = [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; } diff --git a/database/tables_for_magic2.0/users.sql b/database/tables_for_magic2.0/users.sql new file mode 100644 index 0000000..e32cdb9 --- /dev/null +++ b/database/tables_for_magic2.0/users.sql @@ -0,0 +1,15 @@ +-- custom.users definition + +CREATE TABLE `users` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `login` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Логин пользователя', + `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email_verified_at` timestamp NULL DEFAULT NULL, + `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `users_email_unique` (`email`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; \ No newline at end of file diff --git a/database/tables_for_magic2.0/users_202602271736.sql b/database/tables_for_magic2.0/users_202602271736.sql new file mode 100644 index 0000000..0e9954a --- /dev/null +++ b/database/tables_for_magic2.0/users_202602271736.sql @@ -0,0 +1,3 @@ +INSERT INTO custom.users (login,name,email,email_verified_at,password,remember_token,created_at,updated_at) VALUES + ('dgavrilov',NULL,NULL,NULL,NULL,NULL,'2025-11-09 16:50:05','2025-11-09 16:50:05'), + ('developer',NULL,NULL,NULL,NULL,NULL,'2025-11-20 13:45:05','2025-11-20 13:45:05');