Edit File: DelegateUpdateData.php
<?php namespace App\Models; use App\Traits\Uploadable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class DelegateUpdateData extends Model { use HasFactory, Uploadable; protected $fillable = [ 'user_id', 'category_id', 'fullname', 'identity_card_number', 'city_id', 'country_key', 'phone', 'car_type_id', 'car_numbers', 'car_model_id', 'driving_license_image', 'car_license_image', 'delegation_image', 'identity_card_image', 'personal_image', 'car_front_image', 'bank_account_number', 'bank_iban_number', 'bank_name', 'bank_account_owner', 'status', ]; public function category() { return $this->belongsTo(Category::class); } public function carType() { return $this->belongsTo(Cartype::class); } public function carModel() { return $this->belongsTo(CarModel::class); } public function city() { return $this->belongsTo(City::class); } public function user() { return $this->belongsTo(User::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 { $query->Where($key, 'like', '%' . $value . '%'); } } } }); return $query->orderBy('created_at', request()->searchArray && request()->searchArray['order'] ? request()->searchArray['order'] : 'DESC'); } public function setDelegationImageAttribute($value) { if ($value != 'default.png' && $value != null) { $this->attributes['delegation_image'] = $this->uploadFile($value, 'delegation_images', true, 250, null); } } public function setPersonalImageAttribute($value) { if ($value != 'default.png' && $value != null) { $this->attributes['personal_image'] = $this->uploadFile($value, 'users', true, 250, null); } } public function setDrivingLicenseImageAttribute($value) { if ($value != 'default.png' && $value != null) { $this->attributes['driving_license_image'] = $this->uploadFile($value, 'driving_licenses', true, 250, null); } } public function setIdentityCardImageAttribute($value) { if ($value != 'default.png' && $value != null) { // dd('idi'); $this->attributes['identity_card_image'] = $this->uploadFile($value, 'identity_card_images', true, 250, null); } } public function setCarLicenseImageAttribute($value) { if ($value != 'default.png' && $value != null) { $this->attributes['car_license_image'] = $this->uploadFile($value, 'car_licenses', true, 250, null); } } public function setCarFrontImageAttribute($value) { if ($value != 'default.png' && $value != null) { $this->attributes['car_front_image'] = $this->uploadFile($value, 'car_fronts', true, 250, null); } } 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