feat: add UserAvatar model and user relationship
This commit is contained in:
@@ -112,4 +112,8 @@ class User extends Authenticate
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Favorite::class);
|
return $this->hasMany(Favorite::class);
|
||||||
}
|
}
|
||||||
|
public function avatar()
|
||||||
|
{
|
||||||
|
return $this->hasOne(UserAvatar::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Reliese Model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserAvatar
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $file_id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property Carbon $created_at
|
||||||
|
* @property Carbon $updated_at
|
||||||
|
*
|
||||||
|
* @property File $file
|
||||||
|
* @property User $user
|
||||||
|
*
|
||||||
|
* @package App\Models
|
||||||
|
*/
|
||||||
|
class UserAvatar extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'user_avatars';
|
||||||
|
public static $snakeAttributes = false;
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'file_id' => 'int',
|
||||||
|
'user_id' => 'int'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'file_id',
|
||||||
|
'user_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function file()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(File::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user