⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
work
/
modules
/
Tour
/
Blocks
/
Edit File: ListTours.php
<?php namespace Modules\Tour\Blocks; use Modules\Template\Blocks\BaseBlock; use Modules\Tour\Models\Tour; use Modules\Tour\Models\TourCategory; use Modules\Location\Models\Location; class ListTours extends BaseBlock { protected $tourClass; public function __construct(Tour $tourClass) { $this->tourClass = $tourClass; } public function getOptions(){ return [ 'settings' => [ [ 'id' => 'title', 'type' => 'input', 'inputType' => 'text', 'label' => __('Title') ], [ 'id' => 'desc', 'type' => 'input', 'inputType' => 'text', 'label' => __('Desc') ], [ 'id' => 'number', 'type' => 'input', 'inputType' => 'number', 'label' => __('Number Item') ], [ 'id' => 'style', 'type' => 'radios', 'label' => __('Style'), 'values' => [ [ 'value' => 'normal', 'name' => __("Normal") ], [ 'value' => 'carousel', 'name' => __("Slider Carousel") ], [ 'value' => 'box_shadow', 'name' => __("Box Shadow") ], [ 'value' => 'carousel_simple', 'name' => __("Slider Carousel Simple") ], ] ], [ 'id' => 'category_id', 'type' => 'select2', 'label' => __('Filter by Category'), 'select2' => [ 'ajax' => [ 'url' => route('tour.admin.category.category.getForSelect2'), 'dataType' => 'json' ], 'width' => '100%', 'allowClear' => 'true', 'placeholder' => __('-- Select --') ], 'pre_selected'=>route('tour.admin.category.category.getForSelect2',['pre_selected'=>1]) ], [ 'id' => 'location_id', 'type' => 'select2', 'label' => __('Filter by Location'), 'select2' => [ 'ajax' => [ 'url' => route('location.admin.getForSelect2'), 'dataType' => 'json' ], 'width' => '100%', 'allowClear' => 'true', 'placeholder' => __('-- Select --') ], 'pre_selected'=>route('location.admin.getForSelect2',['pre_selected'=>1]) ], [ 'id' => 'order', 'type' => 'radios', 'label' => __('Order'), 'values' => [ [ 'value' => 'id', 'name' => __("Date Create") ], [ 'value' => 'title', 'name' => __("Title") ], ] ], [ 'id' => 'order_by', 'type' => 'radios', 'label' => __('Order By'), 'values' => [ [ 'value' => 'asc', 'name' => __("ASC") ], [ 'value' => 'desc', 'name' => __("DESC") ], ] ], [ 'type'=> "checkbox", 'label'=>__("Only featured items?"), 'id'=> "is_featured", 'default'=>true ], [ 'id' => 'custom_ids', 'type' => 'select2', 'label' => __('List by IDs'), 'select2' => [ 'ajax' => [ 'url' => route('tour.admin.getForSelect2'), 'dataType' => 'json' ], 'width' => '100%', 'multiple' => "true", 'placeholder' => __('-- Select --') ], 'pre_selected' => route('tour.admin.getForSelect2', [ 'pre_selected' => 1 ]) ], ], 'category'=>__("Service Tour") ]; } public function getName() { return __('Tour: List Items'); } public function content($model = []) { $list = $this->query($model); $data = [ 'rows' => $list, 'style_list' => $model['style'], 'title' => $model['title'] ?? "", 'desc' => $model['desc'] ?? "", ]; return view('Tour::frontend.blocks.list-tour.index', $data); } public function contentAPI($model = []){ $rows = $this->query($model); $model['data']= $rows->map(function($row){ return $row->dataForApi(); }); return $model; } public function query($model){ $listTour = $this->tourClass->search($model); $limit = $model['number'] ?? 5; return $listTour->paginate($limit); } }
Simpan