Shop - systeminc/laravel-admin GitHub Wiki
You can access our package Shop
instance with SLA::shop()
.
i.e SLA::shop()->products()
or SLA::shop()->categories()
or SLA::shop()->comments()
or SLA::shop()->orders()
we will return you appropriate Query Builder
.
You can call a method to get Query Builder
, or you can call a property to get a Collection
.
Products
SLA::shop()->products()
will return you Query Builder
, without brackets products
will return Collection
.
For single product SLA::shop()->products()->find($product_id)
we are providing you few methods:
Every product belongsTo
single category on category()
method,
Every product has Gallery
which belongsTo
on method gallery()
,
Every product has multiple comments on relationship hasMany
on method comments()
,
Every product has multiple similar products on method similar()
.
Product categories
SLA::shop()->categories()
will return you Query Builder
, without brackets categories
will return Collection.
Single product categories have hasMany
relationships on method products()
.
SLA::shop()->categories()->find($category_id)->products()
Product comments
SLA::shop()->comments()
will return you Query Builder
, without brackets comments
will return Collection.
Single comments have belongsTo
relationship on method product()
.
SLA::shop()->comments()->find($category_id)->product()
Add comment on product:
SLA::shop()->comments()->create([
'product_id', (int)
'name', (string)
'email', (string)
'message', (text)
'approved', (int) (default 0)
]);
Orders
SLA::shop()->orders()
will return you Query Builder
, without brackets orders
will return Collection.
Place order:
SLA::shop()->orders()->create([
'billing_name'=> 'John Doe',
'billing_email' => '[email protected]',
'billing_address' => 'Some address 12',
'billing_city' => 'Belgrade',
'billing_country' => 'Serbia',
'total_price' => 100,
'shipment_price' => 100,
'valid_until' => 2016-31-8,
'invoice_number' => 123456,
]);
Avaible fields:
'invoice_number', (int)
'order_status_id', (int)
'shipment_price', (int)
'total_price', (int)
'valid_until', (data)
'date_of_purchase', (data)
'currency', (enum)
'note', (text)
'billing_name', (string)
'billing_email', (string)
'billing_telephone', (string)
'billing_address', (string)
'billing_city', (string)
'billing_country', (string)
'billing_postcode', (string)
'billing_contact_person', (string)
'shipping_name', (string)
'shipping_email', (string)
'shipping_telephone', (string)
'shipping_address', (string)
'shipping_city', (string)
'shipping_country', (string)
'shipping_postcode', (string)
'shipping_contact_person',
'parity', (string)
'term_of_payment', (string)
'footnote', (text)
'show_shipping_address', (int)
//ADD item to order
SLA::shop()->orders()->find($order_id)->items()->create([
'order_id', (int)
'product_id', (int)
'quantity', (int)
'discount', (int)
'custom_price' (int)
]);
Available methods:
status()
return order status
items()
return order items