PavaoProposalUnit.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use Illuminate\Database\Eloquent\Relations\HasMany;
  7. use Illuminate\Database\Eloquent\SoftDeletes;
  8. /**
  9. * @property int $id
  10. * @property int $class_package_unit_id
  11. * @property int|null $pavao_proposal_id
  12. * @property float|null $registration_value
  13. * @property bool $registration_included_in_course
  14. * @property bool $registration_installments_allowed
  15. * @property int $registration_max_installments
  16. * @property float|null $classes_value
  17. * @property bool $classes_included_in_course
  18. * @property bool $classes_installments_allowed
  19. * @property int $classes_max_installments
  20. * @property float|null $classes_discount_percentage
  21. * @property float $materials_total_value
  22. * @property bool $materials_included_in_course
  23. * @property bool $materials_installments_allowed
  24. * @property int $materials_max_installments
  25. * @property float|null $total_value
  26. * @property int $total_max_installments
  27. * @property-read \App\Models\ClassPackageUnit $packageUnit
  28. * @property-read \App\Models\PavaoProposal|null $basePavaoProposal
  29. * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\PavaoProposalUnitProduct> $products
  30. */
  31. class PavaoProposalUnit extends Model
  32. {
  33. use HasFactory, SoftDeletes;
  34. protected $table = 'pavao_proposal_units';
  35. protected $guarded = ['id'];
  36. protected $casts = [
  37. 'registration_value' => 'float',
  38. 'registration_included_in_course' => 'boolean',
  39. 'registration_installments_allowed' => 'boolean',
  40. 'registration_max_installments' => 'integer',
  41. 'classes_value' => 'float',
  42. 'classes_included_in_course' => 'boolean',
  43. 'classes_installments_allowed' => 'boolean',
  44. 'classes_max_installments' => 'integer',
  45. 'classes_discount_percentage' => 'float',
  46. 'materials_total_value' => 'float',
  47. 'materials_included_in_course' => 'boolean',
  48. 'materials_installments_allowed' => 'boolean',
  49. 'materials_max_installments' => 'integer',
  50. 'total_value' => 'float',
  51. 'total_max_installments' => 'integer',
  52. ];
  53. public function packageUnit(): BelongsTo
  54. {
  55. return $this->belongsTo(ClassPackageUnit::class, 'class_package_unit_id');
  56. }
  57. public function basePavaoProposal(): BelongsTo
  58. {
  59. return $this->belongsTo(PavaoProposal::class, 'pavao_proposal_id');
  60. }
  61. public function products(): HasMany
  62. {
  63. return $this->hasMany(PavaoProposalUnitProduct::class);
  64. }
  65. }