skip to Main Content

orderBy not working with as keyword laravel query

I'm using query and orderby isn't working $query = Post::query()->latest(); if ($request->input('popular') == 'true') { $query->where('hide_search',0)->orderByDesc('viewer'); } and if ($request->input('popular') == 'true') { $query->where('hide_search',0)->orderByDesc('posts.viewer'); } and if ($request->input('popular') == 'true') { $query->where('hide_search',0)->orderBy('posts.viewer','DESC'); }

VIEW QUESTION

how can I choose one option when I use foreach in laravel

this is code in html : <div class="col-9"> <form> <div class="multiselect"> <div class="selectBox" onclick="showCheckboxes()"> <select> <option placeholder="www"></option> </select> <div class="overSelect"></div> </div> <div id="checkboxes"> @foreach ($subjects as $subject) <label for="itemform"> <input type="radio" value="{{ $subject->id }}"/>{{ $subject->name }} </label> @endforeach </div> @error('subjects')…

VIEW QUESTION

Date validation with another fields in controller in Laravel

Here is my validation code in the controller $eldate = Carbon::now()->addDay(4)->format('Y-m-d'); $validatedData = $this->validate($request, [ 'ldate' => 'required|date|unique:leaves,ldate,NULL,employee,employee,'.auth()->id(), 'ldate2' => 'nullable|date|after_or_equal:ldate', 'type' => 'required' ]); In this validation code I have to add one more condition for date1 If type…

VIEW QUESTION
Back To Top
Search