34 lines
642 B
PHP
34 lines
642 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\FollowStatus;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Follow extends Model
|
|
{
|
|
protected $fillable = [
|
|
'following_id',
|
|
'follower_id',
|
|
'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => FollowStatus::class,
|
|
];
|
|
}
|
|
|
|
public function follower(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'follower_id');
|
|
}
|
|
|
|
public function following(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'following_id');
|
|
}
|
|
}
|