Support the ongoing development of →
posted 5 years ago
Last updated 1 year ago.


I found a solution but is not very elegant :

public function hasdata(){
$pages = $this->pages()->get()->isEmpty();
$episodes = $this->episodes()->get()->isEmpty();
$events = $this->events()->get()->isEmpty();
$teasers = $this->teasers()->get()->isEmpty();
$articles = $this->articles()->get()->isEmpty();
$flag = [$pages, $episodes, $events, $teasers, $articles];
if(in_array(false, $flag)){return true;}
return false;

The solution provided above really works. Thanks! member write my essay today


The quickest approach is an existence query:

select NOT EXISTS (select username from a where username = {$username}) AND NOT EXISTS (select username from b where username = {$username}) AND NOT EXISTS (select username from c where username = {$username});

If your username column is marked as Unique in each table, this should be the most efficient query you will be able to make to perform this operation, and this will outperform a normalized username table in terms of memory usage and, well, virtually any other query that cares about username and another column, as there are no excessive joins. If you've ever been called on to speed up an organization's database, I can assure you that over-normalization is a nightmare. In regards to the advice you've received on normalization in this thread, be wary. It's great for limiting space, or limiting the number of places you have to update data, but you have to weigh that against the maintenance and speed overhead. Take the advice on how to start off an informative essay given to you on this page with a grain of salt.

Get used to running a query analyzer on your queries, if for no other reason than to get in the habit of learning the ramifications of choices when writing queries -- at least until you get your sea legs.


Hi Everyone,

I think to create a view table and call it on ever updated, and maybe even put the whole view table on redis if available, so you will be able to read the table much faster

It is just a idea


Sign in to participate in this thread!


Your banner here too?

visualight visualight Joined 30 Dec 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.