|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Xetaravel\Models\Repositories; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
|
6
|
|
|
use Xetaravel\Models\ShopItem; |
|
7
|
|
|
|
|
8
|
|
|
class ShopItemRepository |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Find the latest shop items for the sidebar. |
|
12
|
|
|
* |
|
13
|
|
|
* @return \Illuminate\Database\Eloquent\Collection |
|
14
|
|
|
*/ |
|
15
|
|
|
public static function sidebar(): Collection |
|
16
|
|
|
{ |
|
17
|
|
|
return ShopItem::latest()->take(config('xetaravel.shop.items_sidebar'))->get(); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Create the new article and save it. |
|
22
|
|
|
* |
|
23
|
|
|
* @param array $data The data used to create the article. |
|
24
|
|
|
* |
|
25
|
|
|
* @return \Xetaravel\Models\ShopItem |
|
26
|
|
|
*/ |
|
27
|
|
|
public static function create(array $data): ShopItem |
|
28
|
|
|
{ |
|
29
|
|
|
return ShopItem::create([ |
|
30
|
|
|
'title' => $data['title'], |
|
31
|
|
|
'shop_category_id' => $data['shop_category_id'], |
|
32
|
|
|
'is_display' => isset($data['is_display']) ? true : false, |
|
33
|
|
|
'content' => $data['content'], |
|
34
|
|
|
'price' => $data['price'], |
|
35
|
|
|
'discount' => $data['discount'], |
|
36
|
|
|
'quantity' => $data['quantity'], |
|
37
|
|
|
]); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Update the shop item data and save it. |
|
42
|
|
|
* |
|
43
|
|
|
* @param array $data The data used to update the shop item. |
|
44
|
|
|
* @param \Xetaravel\Models\ShopItem $item The shop item to update. |
|
45
|
|
|
* |
|
46
|
|
|
* @return \Xetaravel\Models\ShopItem |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function update(array $data, ShopItem $item): ShopItem |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.