|
@@ -2,8 +2,6 @@
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
-use App\Models\Scopes\YearScope;
|
|
|
|
|
-use Illuminate\Database\Eloquent\Attributes\ScopedBy;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
@@ -22,7 +20,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
* 2. in_stock - получено на склад
|
|
* 2. in_stock - получено на склад
|
|
|
* 3. shipped - полностью отгружено (available_qty = 0)
|
|
* 3. shipped - полностью отгружено (available_qty = 0)
|
|
|
*/
|
|
*/
|
|
|
-#[ScopedBy([YearScope::class])]
|
|
|
|
|
class SparePartOrder extends Model
|
|
class SparePartOrder extends Model
|
|
|
{
|
|
{
|
|
|
use HasFactory, SoftDeletes;
|
|
use HasFactory, SoftDeletes;
|
|
@@ -40,7 +37,6 @@ class SparePartOrder extends Model
|
|
|
const DEFAULT_SORT_BY = 'created_at';
|
|
const DEFAULT_SORT_BY = 'created_at';
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
protected $fillable = [
|
|
|
- 'year',
|
|
|
|
|
'spare_part_id',
|
|
'spare_part_id',
|
|
|
'source_text',
|
|
'source_text',
|
|
|
'sourceable_id',
|
|
'sourceable_id',
|
|
@@ -57,7 +53,6 @@ class SparePartOrder extends Model
|
|
|
'with_documents' => 'boolean',
|
|
'with_documents' => 'boolean',
|
|
|
'ordered_quantity' => 'integer',
|
|
'ordered_quantity' => 'integer',
|
|
|
'available_qty' => 'integer',
|
|
'available_qty' => 'integer',
|
|
|
- 'year' => 'integer',
|
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
protected static function boot(): void
|
|
protected static function boot(): void
|
|
@@ -65,9 +60,6 @@ class SparePartOrder extends Model
|
|
|
parent::boot();
|
|
parent::boot();
|
|
|
|
|
|
|
|
static::creating(function ($model) {
|
|
static::creating(function ($model) {
|
|
|
- if (!isset($model->year)) {
|
|
|
|
|
- $model->year = year();
|
|
|
|
|
- }
|
|
|
|
|
if (!isset($model->available_qty)) {
|
|
if (!isset($model->available_qty)) {
|
|
|
$model->available_qty = $model->ordered_quantity;
|
|
$model->available_qty = $model->ordered_quantity;
|
|
|
}
|
|
}
|