Completed
Push — master ( c76df9...ef3d70 )
by Jeff
18:25
created

Order::courier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Shop\Orders;
4
5
use App\Shop\Addresses\Address;
6
use App\Shop\Couriers\Courier;
7
use App\Shop\Customers\Customer;
8
use App\Shop\OrderStatuses\OrderStatus;
9
use App\Shop\Products\Product;
10
use Illuminate\Database\Eloquent\Model;
11
use Sofa\Eloquence\Eloquence;
12
13
class Order extends Model
14
{
15
    use Eloquence;
0 ignored issues
show
Bug introduced by
The trait Sofa\Eloquence\Eloquence requires the property $searchableColumns which is not provided by App\Shop\Orders\Order.
Loading history...
16
17
    /**
18
     * The attributes that are mass assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable = [
23
        'reference',
24
        'courier_id',
25
        'customer_id',
26
        'address_id',
27
        'order_status_id',
28
        'payment',
29
        'discounts',
30
        'total_products',
31
        'total',
32
        'tax',
33
        'total_paid',
34
        'invoice',
35
    ];
36
37
    /**
38
     * The attributes that should be hidden for arrays.
39
     *
40
     * @var array
41
     */
42
    protected $hidden = [];
43
44
    /**
45
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
46
     */
47
    public function products()
48
    {
49
        return $this->belongsToMany(Product::class)
50
                    ->withPivot([
51
                        'quantity',
52
                        'product_name',
53
                        'product_sku',
54
                        'product_description',
55
                        'product_price'
56
                    ]);
57
    }
58
59
    /**
60
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61
     */
62
    public function customer()
63
    {
64
        return $this->belongsTo(Customer::class);
65
    }
66
67
    /**
68
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
69
     */
70
    public function courier()
71
    {
72
        return $this->belongsTo(Courier::class);
73
    }
74
75
    /**
76
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
77
     */
78
    public function address()
79
    {
80
        return $this->belongsTo(Address::class);
81
    }
82
83
    /**
84
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
85
     */
86
    public function orderStatus()
87
    {
88
        return $this->belongsTo(OrderStatus::class);
89
    }
90
91
    /**
92
     * @param string $term
93
     * @param array $options
94
     *
95
     * @return mixed
96
     */
97
    public function searchOrder(string $term, array $options)
98
    {
99
        return static::search($term, $options);
100
    }
101
}
102