![]() Server : Apache System : Linux server2.thebrownbagmedia.com 4.18.0-553.34.1.el8_10.x86_64 #1 SMP Wed Jan 8 09:40:06 EST 2025 x86_64 User : topnotchcv ( 1029) PHP Version : 8.1.32 Disable Function : NONE Directory : /home/topnotchcv/public_html/app/Models/ |
<?php namespace App\Models; use Carbon\Carbon; 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 { use HasRoles; use Notifiable; protected $fillable = [ 'name', 'email', 'password', 'type', 'phone_number', 'profile', 'lang', 'subscription', 'subscription_expire_date', 'parent_id', 'is_active', ]; protected $hidden = [ 'password', 'remember_token', ]; protected $casts = [ 'email_verified_at' => 'datetime', ]; public function totalUser() { return User::whereNotIn('type', ['client', 'advocate'])->where('parent_id', $this->id)->count(); } public function totalTenant() { return User::where('type', 'tenant')->where('parent_id', $this->id)->count(); } public function totalContact() { return Contact::where('parent_id', '=', parentId())->count(); } public function roleWiseUserCount($role) { return User::where('type', $role)->where('parent_id', parentId())->count(); } public static function getDevice($user) { $mobileType = '/(?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera mini|avantgo|mobilesafari|docomo)/i'; $tabletType = '/(?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))/i'; if (preg_match_all($mobileType, $user)) { return 'mobile'; } else { if (preg_match_all($tabletType, $user)) { return 'tablet'; } else { return 'desktop'; } } } public function subscriptions() { return $this->hasOne('App\Models\Subscription', 'id', 'subscription'); } public function clients() { return $this->hasOne('App\Models\Client', 'user_id', 'id'); } public function advocates() { return $this->hasOne('App\Models\Advocate', 'user_id', 'id'); } public function workHistory() { return $this->hasMany('App\Models\AdvocateWorkHistory', 'advocate_id', 'id'); } public static $systemModules = [ 'user', 'client', 'advocate', 'advice', 'case', 'hearing', 'evidence', 'document', 'invoice', 'expense', 'contact', 'note', 'court', 'practice area', 'police station', 'judge', 'matter', 'tag', 'logged history', 'settings', ]; }