fix: fix relations and casts in admin and user models

This commit is contained in:
2026-08-17 08:14:24 +03:30
parent ed02b45269
commit 1c7623be8f
2 changed files with 29 additions and 24 deletions
+25 -20
View File
@@ -7,14 +7,18 @@
namespace App\Models; namespace App\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//use Illuminate\Foundation\Auth\Admin as Authenticate;
//use Illuminate\Foundation\Auth\Admin as Authenticate;
/** /**
* Class Admin * Class Admin
* *
* @property int $id * @property int $id
* @property string $first_name * @property string $full_name
* @property string $last_name * @property string $username
* @property string $email * @property string $email
* @property string $mobile * @property string $mobile
* @property string $password * @property string $password
@@ -24,25 +28,26 @@ use Illuminate\Database\Eloquent\Model;
* *
* @package App\Models * @package App\Models
*/ */
class Admin extends Model class Admin extends User
{ {
protected $table = 'admins'; protected $table = 'admins';
public static $snakeAttributes = false;
protected $casts = [ public static $snakeAttributes = false;
'status' => 'int'
];
protected $hidden = [ protected $casts = [
'password' 'status' => 'int',
]; ];
protected $fillable = [ protected $hidden = [
'first_name', 'password',
'last_name', ];
'email',
'mobile', protected $fillable = [
'password', 'full_name',
'status' 'username',
]; 'email',
'mobile',
'password',
'status',
];
} }
+4 -4
View File
@@ -8,11 +8,11 @@ namespace App\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Auth\User as Authenticate;
/** /**
* Class User * Class User
* *
* @property int $id * @property int $id
* @property string $first_name * @property string $first_name
* @property string $last_name * @property string $last_name
@@ -24,13 +24,13 @@ use Illuminate\Database\Eloquent\Model;
* @property int $status * @property int $status
* @property Carbon $created_at * @property Carbon $created_at
* @property Carbon $updated_at * @property Carbon $updated_at
* *
* @property Collection|Comment[] $comments * @property Collection|Comment[] $comments
* @property Collection|Favorite[] $favorites * @property Collection|Favorite[] $favorites
* *
* @package App\Models * @package App\Models
*/ */
class User extends Model class User extends Authenticate
{ {
protected $table = 'users'; protected $table = 'users';
public static $snakeAttributes = false; public static $snakeAttributes = false;