You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
805 B

<?php
namespace App\Entities\Agencies;
use App\Entities\Users\User;
use Illuminate\Database\Eloquent\Model;
class Agency extends Model
{
protected $fillable = ['name', 'email', 'address', 'phone', 'website', 'owner_id'];
public function owner()
{
return $this->belongsTo('App\Entities\Users\User');
}
public function projects()
{
return $this->hasMany('App\Entities\Projects\Project', 'owner_id');
}
public function workers()
{
return $this->belongsToMany('App\Entities\Users\User', 'agency_workers', 'agency_id', 'worker_id');
}
public function addWorker(User $worker)
{
$this->workers()->attach($worker);
}
public function removeWorker(User $worker)
{
$this->workers()->detach($worker);
}
}