// SYSTEM PANEL //
[ROOT]
/
mnt
/
pleskStorage
/
vhosts
/
kodsolutions.net
/
subdomains
/
go-rent.kodsolutions.net
/
app
/
Models
[ PARENT ]
EDIT :: User.php
<?php namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use App\Helpers\Constants; use App\Models\Car\Car; use App\Models\Car\CarRental; use App\Models\Office\Office; use Laravel\Sanctum\HasApiTokens; use Spatie\MediaLibrary\HasMedia; use Illuminate\Notifications\Notifiable; use Spatie\MediaLibrary\InteractsWithMedia; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable implements HasMedia { use HasApiTokens, HasFactory, Notifiable; use InteractsWithMedia; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'name', 'email', 'password', 'phone', 'image', 'full_phone', 'phone_code', 'type', //'resident', 'tourist', 'office' 'gender', 'active', 'is_verify', 'office_id', 'id_card_number', 'driving_license_number', 'passport_number', 'international_license_number', 'visa_copy_url', 'first_name', 'last_name', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; public function setPasswordAttribute($pass) { $this->attributes['password'] = bcrypt($pass); } public function scopeRecent($query) { return $query->orderBy('id', 'desc'); } public function scopePublish($query) { return $query->where('active', 1); } public function scopeUser($query) { return $query->whereIn('type', ['resident', 'tourist', 'office']); } public function office() { return $this->belongsTo(Office::class); } public function getImagesAttribute() { $images = []; $files = $this->getMedia('document'); if (!empty($files)) { foreach ($files as $file) { array_push($images, $file->getFullUrl()); } } return $images; } public function rentals() { return $this->hasMany(CarRental::class); } public function favorites() { return $this->belongsToMany(Car::class, 'favourites', 'user_id', 'car_id'); } }
SAVE
CANCEL