Kundenentscheid 26.08. (D-5): Eingang und Ausgang haben eigene, pflegbare Gründe-Listen statt einer festen Liste im Controller. - Neues Modell/Tabelle stock_movement_reasons (label, direction in/out, pos, active, SoftDeletes) inkl. Seed der bisherigen Gründe sinnvoll auf Ein-/Ausgang aufgeteilt. - CRUD wie DisposalReason (SettingCrudController + FormRequest + Formular mit Richtungs-Auswahl); zwei Listen (Eingangs-/Ausgangs-Gründe) auf der Seite Einstellungen → Allgemeines, „Neu anlegen" mit vorbelegter Richtung. - Produktbestand-Maske: das Grund-Dropdown wird jetzt je nach Eingang/Ausgang per JS aus den passenden, gepflegten Gründen befüllt (manualReasons entfernt). - DeletionGuard: StockMovementReason immer löschbar. Migration create_stock_movement_reasons auf Dev-/Live-DB. 4 Tests, Suite 326 grün. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
851 B
PHP
42 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* AP-48: Pflegbarer Buchungsgrund für den Produktbestand, getrennt nach Richtung
|
|
* (in = Eingang, out = Ausgang).
|
|
*/
|
|
class StockMovementReason extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'label',
|
|
'direction',
|
|
'active',
|
|
'pos',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param Builder<StockMovementReason> $query
|
|
* @return Builder<StockMovementReason>
|
|
*/
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query->where('active', true);
|
|
}
|
|
}
|