ProductionOrderInstallation.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Models;
  4. use Database\Factories\ProductionOrderInstallationFactory;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  8. use Illuminate\Database\Eloquent\Relations\HasMany;
  9. use Illuminate\Database\Eloquent\SoftDeletes;
  10. class ProductionOrderInstallation extends Model
  11. {
  12. /** @use HasFactory<ProductionOrderInstallationFactory> */
  13. use HasFactory;
  14. use SoftDeletes;
  15. protected $fillable = [
  16. 'production_order_id',
  17. 'installation_date',
  18. 'installation_days',
  19. 'brigadier_id',
  20. 'note',
  21. 'created_by',
  22. 'updated_by',
  23. ];
  24. protected function casts(): array
  25. {
  26. return [
  27. 'production_order_id' => 'integer',
  28. 'installation_date' => 'immutable_date',
  29. 'installation_days' => 'integer',
  30. 'brigadier_id' => 'integer',
  31. 'created_by' => 'integer',
  32. 'updated_by' => 'integer',
  33. ];
  34. }
  35. public function productionOrder(): BelongsTo
  36. {
  37. return $this->belongsTo(ProductionOrder::class);
  38. }
  39. public function brigadier(): BelongsTo
  40. {
  41. return $this->belongsTo(User::class, 'brigadier_id');
  42. }
  43. public function schedules(): HasMany
  44. {
  45. return $this->hasMany(Schedule::class);
  46. }
  47. }