28 lines
654 B
PHP
28 lines
654 B
PHP
<?php
|
|
|
|
namespace Modules\Adjustment\Entities;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class Adjustment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
public function getDateAttribute($value) {
|
|
return Carbon::parse($value)->format('d M, Y');
|
|
}
|
|
|
|
public function adjustedProducts() {
|
|
return $this->hasMany(AdjustedProduct::class, 'adjustment_id', 'id');
|
|
}
|
|
|
|
public function getReferenceAttribute($value) {
|
|
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT );
|
|
}
|
|
|
|
}
|