2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Watson\Validating\ValidatingTrait;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Group extends Model
|
|
|
|
{
|
|
|
|
protected $table = 'groups';
|
|
|
|
|
|
|
|
public $rules = array(
|
|
|
|
'name' => 'required|min:3|max:255',
|
|
|
|
);
|
|
|
|
|
2016-04-28 14:03:54 -07:00
|
|
|
/**
|
|
|
|
* Whether the model should inject it's identifier to the unique
|
|
|
|
* validation rules before attempting validation. If this property
|
|
|
|
* is not set in the model it will default to true.
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
protected $injectUniqueIdentifier = true;
|
|
|
|
use ValidatingTrait;
|
|
|
|
|
|
|
|
|
2016-04-28 14:03:54 -07:00
|
|
|
/**
|
|
|
|
* Get user groups
|
|
|
|
*/
|
2016-03-25 01:18:05 -07:00
|
|
|
public function users()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany('\App\Models\User', 'users_groups');
|
|
|
|
}
|
2016-04-28 14:03:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
public function decodePermissions()
|
|
|
|
{
|
|
|
|
return json_decode($this->permissions, true);
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|