1 | <?php |
||
35 | class Rate extends Model |
||
36 | { |
||
37 | use ValidatingTrait; |
||
38 | use CacheableEloquent; |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | protected $fillable = [ |
||
44 | 'bookable_id', |
||
45 | 'bookable_type', |
||
46 | 'percentage', |
||
47 | 'operator', |
||
48 | 'amount', |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | protected $casts = [ |
||
55 | 'bookable_id' => 'integer', |
||
56 | 'bookable_type' => 'string', |
||
57 | 'percentage' => 'float', |
||
58 | 'operator' => 'string', |
||
59 | 'amount' => 'integer', |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | protected $observables = [ |
||
66 | 'validating', |
||
67 | 'validated', |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * The default rules that the model will validate against. |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | protected $rules = [ |
||
76 | 'bookable_id' => 'required|integer', |
||
77 | 'bookable_type' => 'required|string', |
||
78 | 'percentage' => 'required|numeric|min:-100|max:100', |
||
79 | 'operator' => 'required|string|in:^,<,>,=', |
||
80 | 'amount' => 'required|integer|max:10000000', |
||
81 | ]; |
||
82 | |||
83 | /** |
||
84 | * Whether the model should throw a |
||
85 | * ValidationException if it fails validation. |
||
86 | * |
||
87 | * @var bool |
||
88 | */ |
||
89 | protected $throwValidationExceptions = true; |
||
90 | |||
91 | /** |
||
92 | * Create a new Eloquent model instance. |
||
93 | * |
||
94 | * @param array $attributes |
||
95 | */ |
||
96 | public function __construct(array $attributes = []) |
||
102 | |||
103 | /** |
||
104 | * Get the owning resource model. |
||
105 | * |
||
106 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
107 | */ |
||
108 | public function bookable(): MorphTo |
||
112 | } |
||
113 |