Skip to content
Advertisement

Tag: laravel

Laravel 5.6.9 – database count gives different outputs

Does anyone know why these two ways to count numbers of users in my table give different answers when i run them in tinker? AppModelsUser::count() => 92269 $count = DB::table(‘users’)->count() => 92829 Running a SQL query in Sequel Pro gives 92829. Answer If you have the SoftDelete trait on your User model then when you query via the Model it

Booking Time slot, with Equipment Stock query, in Laravel

Here’s an interesting one for you all. I’ve found myself in a implementation conundrum. I’m developing a booking app in Laravel that allows people to book rooms and equipment for spaces at specific times. The amount of equipment available is limited, so the amount of stock has to be queried in tandem with the time slots associated with the booking.

Get a value from two tables

I am trying to get the value of the colum “name” from the clubs table. First table:(Clubs) id* name (what i need!!!) email password Second table:(club_posts) id club_id* zip_id kategory type stadt plz Controller: This is my query: The result is an array with ten values, but need only one. Answer Create a relation club in you ClubPost Model so

Multiple LIKE clauses in Laravel Eloquent

I currently have this code in my controller: The above code works, but what I want is to get “Accounting” and “Web Design” from an array, and just loop through that array so that the query is dynamic instead of hard coded on the controller Answer Try this :

Advertisement