Viewing file: User.php (2.6 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\DB; use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements MustVerifyEmail { use Notifiable, HasRoles;
/** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'role_id' ];
/** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ];
/** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ];
public static function getpermissionGroups() { $permission_groups = DB::table('permissions') ->select('group_name as name') ->groupBy('group_name') ->get(); return $permission_groups; }
public static function getPermissionGroup() { return $permission_groups = DB::table('permissions')->select('group_name')->groupBy('group_name')->get(); } public static function getpermissionsByGroupName($group_name) { $permissions = DB::table('permissions') ->select('name', 'id') ->where('group_name', $group_name) ->get(); return $permissions; }
public function term() { return $this->hasMany('App\Terms', 'use_id', 'id'); }
public static function roleHasPermissions($role, $permissions) { $hasPermission = true; foreach ($permissions as $permission) { if (!$role->hasPermissionTo($permission->name)) { $hasPermission = false; return $hasPermission; } } return $hasPermission; }
public function usermeta() { return $this->hasOne('App\Usermeta')->where('type','content'); }
public function user_domain() { return $this->belongsTo('App\Domain','domain_id','id'); }
public function orders() { return $this->hasMany('App\Order','customer_id','id'); } public function orders_complete() { return $this->hasMany('App\Order','customer_id','id')->where('status','completed'); }
public function orders_processing() { return $this->hasMany('App\Order','customer_id','id')->where('status','!=','completed')->where('status','!=','canceled'); }
}
|