| Total Complexity | 3 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class Item extends Component |
||
| 14 | { |
||
| 15 | use WithPagination; |
||
| 16 | use WithSorting; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The string to search. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | public string $search = ''; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Used to update in URL the query string. |
||
| 27 | * |
||
| 28 | * @var string[] |
||
| 29 | */ |
||
| 30 | protected $queryString = ['sortField', 'sortDirection']; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * The theme used for pagination. |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected string $paginationTheme = 'bootstrap'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Function to render the component. |
||
| 41 | * |
||
| 42 | * @return View |
||
| 43 | */ |
||
| 44 | public function render() |
||
| 45 | { |
||
| 46 | return view('livewire.admin.shop.item', [ |
||
| 47 | 'items' => $this->items |
||
|
|
|||
| 48 | ]); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Create and return the query for the items. |
||
| 53 | * |
||
| 54 | * @return Builder |
||
| 55 | */ |
||
| 56 | public function getItemsQueryProperty(): Builder |
||
| 57 | { |
||
| 58 | $query = ShopItem::query() |
||
| 59 | ->search('title', $this->search); |
||
| 60 | |||
| 61 | return $this->applySorting($query); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Build the query and paginate it. |
||
| 66 | * |
||
| 67 | * @return LengthAwarePaginator |
||
| 68 | */ |
||
| 69 | public function getItemsProperty(): LengthAwarePaginator |
||
| 72 | } |
||
| 73 | } |
||
| 74 |