Edit File: DelegateJoinrequest.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use File; use App\Traits\Uploadable; use Illuminate\Database\Eloquent\Model; class DelegateJoinrequest extends Model { protected $fillable = ['user_id','personal_image','qr','fullname','identity_card_number','identity_card','identity_number','nationality_id', 'driver_date_of_birth','sponsor_name','city_id','email','country_id', 'phone','address','company_id','category_id','car_type_id','car_model_id', 'car_numbers','driving_license_image','car_license_image','delegation_image','identity_card_image', 'car_front_image','bank_account_number','bank_iban_number','bank_name','bank_account_owner', 'seen','status','name']; use HasFactory,Uploadable; public function setDelegationImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['delegation_image'] = $this->uploadOne($value, 'delegation_images', 'image'); } } public function setPersonalImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['personal_image'] = $this->uploadOne($value, 'users','image'); } } public function setDrivingLicenseImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['driving_license_image'] = $this->uploadOne($value, 'driving_licenses','image'); } } public function getCommercialImagePathAttribute() { return asset( 'assets/uploads/commercial_images/' . $this->commercial_image ); } public function setIdentityCardImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['identity_card_image'] = $this->uploadOne($value, 'identity_card_images', 'image'); } } public function setCommercialImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['commercial_image'] = $this->uploadOne($value, 'commercial_images','image'); } } public function category(){ return $this->belongsTo(Category::class); } public function scopeSearch( $query, $searchArray = [] ) { $query->where( function ( $query ) use ( $searchArray ) { if ( $searchArray ) { foreach ( $searchArray as $key => $value ) { if ( str_contains( $key, '_id' ) ) { if ( null != $value ) { $query->Where( $key, $value ); } } elseif ( 'order' == $key ) { } elseif ( 'created_at_min' == $key ) { if ( null != $value ) { $query->WhereDate( 'created_at', '>=', $value ); } } elseif ( 'created_at_max' == $key ) { if ( null != $value ) { $query->WhereDate( 'created_at', '<=', $value ); } } else { if ( null != $value ) { $query->Where( $key, 'like', '%' . $value . '%' ); } } } } } ); return $query->orderBy( 'created_at', request()->searchArray && request()->searchArray[ 'order' ] ? request()->searchArray[ 'order' ] : 'DESC' ); } public function nationality() { return $this->belongsTo(Nationality::class); } public function region() { return $this->belongsTo(Region::class); } public function city() { return $this->belongsTo(City::class); } public function carType() { return $this->belongsTo(Cartype::class); } public function carModel() { return $this->belongsTo(CarModel::class); } public function user() { return $this->belongsTo(User::class); } public function setCarLicenseImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['car_license_image'] = $this->uploadOne($value, 'car_licenses','image'); } } public function setCarFrontImageAttribute($value) { if($value != 'default.png' && $value != null) { $this->attributes['car_front_image'] = $this->uploadOne($value, 'car_fronts', 'image'); } } public function getDrivingLicenseImagePathAttribute() { $driving_license = $this->attributes['driving_license_image'] == NULL ? 'default.png' : $this->attributes['driving_license_image']; return asset('assets/uploads/driving_licenses/' . $driving_license); } public function getDelegationImagePathAttribute() { $delegation = $this->attributes['delegation_image'] == NULL ? 'default.png' : $this->attributes['delegation_image']; return asset( 'assets/uploads/delegation_images/' . $delegation ); } public function getIdentityCardImagePathAttribute() { $Id = $this->attributes['identity_card_image'] == NULL ? 'default.png' : $this->attributes['identity_card_image']; return asset( 'assets/uploads/identity_card_images/' . $Id ); } public function getCarLicenseImagePathAttribute() { $carLicense = $this->attributes['car_license_image'] == NULL ? 'default.png' : $this->attributes['car_license_image']; return asset( 'assets/uploads/car_licenses/' . $carLicense ); } public function getCarFrontImagePathAttribute() { $carLicense = $this->attributes['car_front_image'] == NULL ? 'default.png' : $this->attributes['car_front_image']; return asset( 'assets/uploads/car_fronts/' . $carLicense); } public function getPersonalImagePathAttribute() { $delegation = $this->attributes['personal_image'] == NULL ? 'default.png' : $this->attributes['personal_image']; return asset( 'assets/uploads/users/' . $delegation ); } }
Back to File Manager