Files
monica/app/Models/Account/AddressBook.php
T
2020-12-15 08:54:27 +01:00

72 lines
1.3 KiB
PHP

<?php
namespace App\Models\Account;
use App\Models\User\User;
use App\Models\Contact\Contact;
use App\Models\ModelBinding as Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AddressBook extends Model
{
protected $table = 'addressbooks';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'account_id',
'user_id',
'name',
'description',
];
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
];
/**
* Get the account record associated with the address book.
*
* @return BelongsTo
*/
public function account()
{
return $this->belongsTo(Account::class);
}
/**
* Get the user record associated with the address book.
*
* @return BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get all contacts for this address book.
*
* @return HasMany
*/
public function contacts()
{
return $this->hasMany(Contact::class);
}
}