skip to Main Content

Laravel – Searching posts by tags

I need to show posts by tags. My solution works for single tag and it looks as follows: Route: Route::get('/posts', [PostController::class, 'index'])->middleware('auth'); Post model filter: public function scopeFilter($query, array $filters) { if ($filters['tag'] ?? false) { $tagId = Tag::where('name', $filters['tag'])->first()->id;…

VIEW QUESTION

Kyslik/column-sortable in laravel 10

I have project in laravel 10 with kyslik/column-sortable. When I get route: Route::get("/test", [searchEngineController::class, 'sort']); and in searchEngineController::sort: public function sort() { $products = Products::sortable()->paginate(5); return view('test', compact('products')); } and in view: <table class="table table-bordered"> <tr> <th width="80px">@sortablelink('id')</th> <th>@sortablelink('Name')</th> <th>@sortablelink('Second_data')</th>…

VIEW QUESTION

laravel foreach loop with 2k and get relation from 200k tack long long time

i have this model called Product and i have model called Note_voucher_line and this is relation inside product public function get_note_voucher_lines() { return $this->hasMany('AppModelsNote_voucher_line','product_id','id')->orderBy('date','asc')->orderBy('note_voucher_id','asc'); } now sometimes i have to loop products like this code $products = Product::whereBetween('id',[$num1,$num2])->get(); foreach($products as…

VIEW QUESTION
Back To Top
Search