mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
802dc9240d
PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.
65 lines
1.5 KiB
PHP
Executable file
65 lines
1.5 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Traits\Searchable;
|
|
use Watson\Validating\ValidatingTrait;
|
|
|
|
class Group extends SnipeModel
|
|
{
|
|
protected $table = 'permission_groups';
|
|
|
|
public $rules = [
|
|
'name' => 'required|min:2|max:255',
|
|
];
|
|
|
|
/**
|
|
* 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 bool
|
|
*/
|
|
protected $injectUniqueIdentifier = true;
|
|
use ValidatingTrait;
|
|
use Searchable;
|
|
|
|
/**
|
|
* The attributes that should be included when searching the model.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $searchableAttributes = ['name', 'created_at'];
|
|
|
|
/**
|
|
* The relations and their attributes that should be included when searching the model.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $searchableRelations = [];
|
|
|
|
/**
|
|
* Establishes the groups -> users relationship
|
|
*
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
* @since [v1.0]
|
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
*/
|
|
public function users()
|
|
{
|
|
return $this->belongsToMany(\App\Models\User::class, 'users_groups');
|
|
}
|
|
|
|
/**
|
|
* Decode JSON permissions into array
|
|
*
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
* @since [v1.0]
|
|
* @return array
|
|
*/
|
|
public function decodePermissions()
|
|
{
|
|
return json_decode($this->permissions, true);
|
|
}
|
|
}
|