/
home
/
henzagold
/
server
/
app
/
Models
/
File Upload :
llllll
Current File: //home/henzagold/server/app/Models/CustomOrder.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Customer; use Morilog\Jalali\Jalalian; class CustomOrder extends Model { use HasFactory, SoftDeletes, Selector; protected $appends = ['sts_str_en','sts_str_fa','time_creat_fa','time_update_fa']; protected $fillable = [ 'customer_id', 'file_id', 'city_id', 'weight', 'color', 'size', 'sum', 'color_stone', 'color_mina', 'workshop_id', 'sts' // Added since it's in your validation ]; protected $casts = [ 'sts' => 'integer', 'customer_id' => 'integer', 'file_id' => 'integer', 'city_id' => 'integer', 'weight' => 'float', 'sum' => 'float', 'deleted_at' => 'datetime' // For SoftDeletes ]; static $STS_EN = [ 1 => 'Order Registered', 2 => 'Admin Approved', 3 => 'Workshop Approved', 4 => 'Manufactured & Ready for Shipment', 5 => 'Delivered', 6 => 'Cancelled', // Only Admin ]; static $STS_FA = [ 1 => 'ثبت سفارش', 2 => 'تایید ادمین', 3 => 'تایید کارگاه', 4 => 'ساخته شده آماده ارسال', 5 => 'تحویل شده', 6 => 'لغو', // فقط ادمین ]; public function getTimeCreatFaAttribute() { return Jalalian::fromDateTime($this->attributes['created_at'])->format('Y/m/d-H:i:s'); } public function getTimeUpdateFaAttribute() { return Jalalian::fromDateTime($this->attributes['updated_at'])->format('Y/m/d-H:i:s'); } public function getStsStrEnAttribute() { return self::$STS_EN[$this->attributes['sts']] ?? 'Not defined'; } public function getStsStrFaAttribute() { return self::$STS_FA[$this->attributes['sts']] ?? 'تعریف نشده'; // Better Persian for "Not defined" } public function file() { return $this->belongsTo('App\Models\Image', 'file_id');//->select(['id' , 'image' , Image::$SELECT_FULL]); } public function customer() { return $this->belongsTo(Customer::class)->select(['*']); } public function CustomOrderLog() { return $this->hasMany(CustomOrderLog::class) ->orderBy('created_at', 'desc'); } }
Copyright ©2k19 -
Hexid
|
Tex7ure