Файловый менеджер - Редактировать - /home/clickysoft/public_html/app/Models/Asset.php
Назад
<?php namespace App\Models; use Carbon\Carbon; use DateTimeInterface; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; class Asset extends Model implements HasMedia { use InteractsWithMedia, HasFactory; public $table = 'assets'; protected $appends = [ 'asset_image', ]; protected $dates = [ 'asset_expiration_date', 'next_audit_date', 'purchase_date', 'eol_date', 'created_at', 'updated_at', ]; protected $fillable = [ 'organization_id', 'asset_name', 'asset_status_id', 'category_id', 'manufacturer_id', 'supplier_id', 'company_id', 'branch_id', 'qty', 'purchase_cost', 'currency_id', 'notes', 'asset_expiration_date', 'next_audit_date', 'purchase_date', 'eol_date', 'created_at', 'updated_at', ]; protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('thumb')->fit('crop', 100, 100); $this->addMediaConversion('preview')->fit('crop', 200, 200); } public function organization() { return $this->belongsTo(Organization::class, 'organization_id'); } public function asset_status() { return $this->belongsTo(Status::class, 'asset_status_id'); } public function category() { return $this->belongsTo(Category::class, 'category_id'); } public function manufacturer() { return $this->belongsTo(Manufacturer::class, 'manufacturer_id'); } public function supplier() { return $this->belongsTo(Supplier::class, 'supplier_id'); } public function company() { return $this->belongsTo(Company::class, 'company_id'); } public function branch() { return $this->belongsTo(Branch::class, 'branch_id'); } public function getAssetImageAttribute() { $file = $this->getMedia('asset_image')->last(); if ($file) { $file->url = $file->getUrl(); $file->thumbnail = $file->getUrl('thumb'); $file->preview = $file->getUrl('preview'); } return $file; } public function getAssetExpirationDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setAssetExpirationDateAttribute($value) { $this->attributes['asset_expiration_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function getNextAuditDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setNextAuditDateAttribute($value) { $this->attributes['next_audit_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function getPurchaseDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setPurchaseDateAttribute($value) { $this->attributes['purchase_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function getEolDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setEolDateAttribute($value) { $this->attributes['eol_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function currency() { return $this->belongsTo(Currency::class, 'currency_id'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка