| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Models; |
| 4 |
|
| 5 |
class OrderItem extends Model |
| 6 |
{ |
| 7 |
/** |
| 8 |
* The table associated with the model. |
| 9 |
* |
| 10 |
* @var string |
| 11 |
*/ |
| 12 |
protected $table = 'fluentform_order_items'; |
| 13 |
|
| 14 |
/** |
| 15 |
* An order item belongs to a form. |
| 16 |
* |
| 17 |
* @return \FluentForm\Framework\Database\Orm\Relations\BelongsTo |
| 18 |
*/ |
| 19 |
public function form() |
| 20 |
{ |
| 21 |
return $this->belongsTo(Form::class, 'form_id', 'id'); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* An order item belongs to a submission. |
| 26 |
* |
| 27 |
* @return \FluentForm\Framework\Database\Orm\Relations\BelongsTo |
| 28 |
*/ |
| 29 |
public function submission() |
| 30 |
{ |
| 31 |
return $this->belongsTo(Submission::class, 'submission_id', 'id'); |
| 32 |
} |
| 33 |
|
| 34 |
public function scopeBySubmission($query, $submissionId) |
| 35 |
{ |
| 36 |
return $query->where('submission_id', $submissionId); |
| 37 |
} |
| 38 |
|
| 39 |
public function scopeProducts($query) |
| 40 |
{ |
| 41 |
return $query->where('type', '!=', 'discount'); |
| 42 |
} |
| 43 |
|
| 44 |
public function scopeDiscounts($query) |
| 45 |
{ |
| 46 |
return $query->where('type', 'discount'); |
| 47 |
} |
| 48 |
} |
| 49 |
|