File: /var/www/wsklad/app/MobileSaleDocumentHistory.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MobileSaleDocumentHistory extends Model
{
protected $table = 'mobile_sale_documents_history';
protected $guarded = [];
public $timestamps = true;
public function details()
{
return $this->hasMany(MobileSaleDocumentDetailHistory::class, 'mobilesaledocument_id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function distributor()
{
return $this->hasOne('App\Ajurendpointdistributor', 'F_KONTRAGENT', 'distributorCode');
}
public function paymentMethod()
{
return $this->hasOne('App\Ajurendpointpaymentmethod', 'PAYMENT', 'payment');
}
public function distributorDetails()
{
return $this->hasOne('App\Distributordetail', 'F_KONTRAGENT', 'distributorCode');
}
public function receiverData()
{
return $this->hasOne('App\Ajurendpointreceiver', 'F_KONTRAGENT', 'receiver');
}
public function inMaker()
{
return $this->hasOne('App\User', 'id', 'eSkladOperator');
}
public function getDocTypeNameAttribute()
{
$docTypeNames = [
'invoice' => 'Фактура',
'billOfGoods' => 'Стокова разписка',
'creditNote' => 'Кредитно известие',
'debitNote' => 'Дебитно известие',
];
return $docTypeNames[$this->docType] ?? 'Неизвестен';
}
public static function getDocTypeName($docType)
{
$docTypeNames = [
'invoice' => 'Фактура',
'billOfGoods' => 'Стокова разписка',
'creditNote' => 'Кредитно известие',
'debitNote' => 'Дебитно известие',
];
return $docTypeNames[$docType] ?? 'Неизвестен';
}
/**
* Get the human-readable name for the action field.
*
* @return string
*/
public function getActionNameAttribute()
{
$actionNames = [
'delete' => 'изтриване на ред',
'create' => 'добавяне на ред',
'update' => 'редакция на ред',
'changeReceiver' => 'смяна на получател',
];
return $actionNames[$this->action] ?? 'Неизвестно действие';
}
/**
* Static method to get the human-readable name for a given action code.
*
* @param string $action
* @return string
*/
public static function getActionName($action)
{
$actionNames = [
'delete' => 'изтриване на ред',
'create' => 'добавяне на ред',
'update' => 'редакция на ред',
'changeReceiver' => 'смяна на получател',
];
return $actionNames[$action] ?? 'Неизвестно действие';
}
protected $appends = [
'docTypeName',
'actionName',
];
protected $casts = [
'payment' => 'string',
];
}