Files
UNIT3D-Community-Edition/app/Group.php
HDVinnie d797066370 (Fix) Group Settings
- This closes #75
2018-03-07 11:42:40 -05:00

60 lines
1.2 KiB
PHP
Executable File

<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App;
use Illuminate\Database\Eloquent\Model;
class Group extends Model
{
public $timestamps = false;
/**
* Validation rules
*
*/
public $rules = [
'name' => 'required',
'slug' => 'required',
'position' => 'required',
'color' => 'required',
'icon' => 'required',
];
/**
* Has many users
*
*/
public function users()
{
return $this->hasMany(\App\User::class);
}
/**
* Has many permissions
*
*/
public function permissions()
{
return $this->hasMany(\App\Permission::class);
}
/**
* Returns the requested row from the permissions table
*
*/
public function getPermissionsByForum($forum)
{
return Permission::whereRaw('forum_id = ? AND group_id = ?', [$forum->id, $this->id])->first();
}
}