One Hat Cyber Team
Your IP :
18.117.241.170
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
food.electronharmony.com
/
app
/
Models
/
View File Name :
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); } }