Files
monica/app/Tag.php
T
Régis Freyd 7e1cd96bf5 Add API (#606)
This is the first part of the API. It supports most of contacts, as well as the
journal. This PR also brings Monica to Laravel 5.5, as the API required it with
the new concept of resources. It needs to run `php artisan migrate` as well as
`php artisan passport:keys` to generate the access tokens needed for the API.
2017-10-30 08:38:15 -04:00

50 lines
891 B
PHP

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
];
/**
* Get the account record associated with the debt.
*/
public function account()
{
return $this->belongsTo('App\Account');
}
/**
* Get the contact record associated with the debt.
*/
public function contacts()
{
return $this->belongsToMany('App\Contact')->withPivot('account_id')->withTimestamps();
}
/**
* Update the slug.
*/
public function updateSlug()
{
$this->name_slug = str_slug($this->name);
$this->save();
}
}