dealhub/app/Models/Broker.php
kusowl 587893511c wip: live support chat
- add migration
- setup models
- generate phpdoc via helper
2026-02-11 12:27:58 +05:30

59 lines
2.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
/**
* @property int $id
* @property string|null $bio
* @property string|null $location
* @property string|null $phone
* @property bool $verified
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Follow|null $pivot
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Customer> $followers
* @property-read int|null $followers_count
* @property-read \App\Models\User|null $user
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereBio($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereLocation($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Broker whereVerified($value)
* @mixin \Eloquent
*/
class Broker extends Model
{
protected $fillable = ['bio', 'location', 'phone'];
protected function casts(): array
{
return [
'verified' => 'boolean',
];
}
public function user(): MorphOne
{
return $this->morphOne(User::class, 'role');
}
public function followers(): BelongsToMany
{
return $this->belongsToMany(
Customer::class,
'follows',
'broker_id',
'customer_id'
)->using(Follow::class);
}
}