File: /var/www/wsklad/app/MobileSaleDocumentDeletedHistory.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MobileSaleDocumentDeletedHistory extends Model
{
protected $table = 'mobile_sale_documents_deleted_history';
protected $guarded = [];
public $timestamps = true;
public function details()
{
return $this->hasMany(MobileSaleDocumentDetailDeletedHistory::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] ?? 'Неизвестен';
}
protected $appends = [
'docTypeName',
];
protected $casts = [
'payment' => 'string',
];
}