skip to Main Content

Bug with Laravel Eloquent query buldier

I found a weird situation when nesting in a query a where with a orWhereNull. The result is returning rows with values that are neither null nor correct This is the code: $query = Document::where("active", true)->where("type_id", $document_type->id); if($selected) { $query->where(function($q)…

VIEW QUESTION

how to access REST API in laravel 10?

I'm working on a project using laravel 10 that uses REST API but I'm getting a 404 not found error when I tried to test the url http://localhost/api/v1/continent with GET request in Postman. this is my routes/api.php: Route::prefix('v1')->name('v1.')->group(function() { Route::get('continent',…

VIEW QUESTION

Making a CommonController in laravel

Most of my controllers in laravel look the same Example: class CourseController extends Controller { public function index(Request $request) { $courses = Course::query(); $courses = $this->commonIndex($courses, $request); return CourseResource::collection($courses); } public function store(StoreCourseRequest $request) { $course = Course::create($request->validated); return CourseResource::make($course);…

VIEW QUESTION

Php versions – Which method to use for Laravel Collection to find a Date between two DateTime

$period = new DatePeriod( new DateTime('2024-03-20 00:00:00'), new DateInterval('P1D'), new DateTime('2024-03-28 23:59:59') ); $suppliersInfo = OrderProduct::whereNotNull('brand') ->whereBetween('updated_at', [$startDate, $endDate ])->get(); $labels = []; foreach ($period as $date){ $labels[] = $date->format('d-m-Y'); $dateToSearch = $date->format('Y-m-d'); $orderCount = $suppliersInfo->where( 'updated_at' , $dateToSearch )…

VIEW QUESTION
Back To Top
Search