Understood. And thanks for the snippet, I will play around with it.
My main page is an HQ of sorts and grabs instances of all Models (albeit, only a few of them). But it loads in the following fashion:
- Single Instance of ModelA
- 5 Instances of ModelB
- 4 Instances of ModelC
- Vue api call to load ModelD
In some cases, there is no data (new or updated) and I just need to return a string to indicate so. That's the basis for my question which led to BEST PRACTICE thought process.
Thanks for chiming in!
EDIT TO ADD:
I was familiar with exists() but after reading Laravel Docs I thought it was used against query constraints and not to determine if a single instance exists.
https://laravel.com/docs/5.8/queries#where-exists-clauses
** Determining If Records Exist **
Instead of using the count method to determine if any records exist that match your query's constraints, you may use the exists and doesntExist methods:
return DB::table('orders')->where('finalized', 1)->exists();
return DB::table('orders')->where('finalized', 1)->doesntExist();