I'm trying to find out if my table is empty but I get this error
Call to undefined function App\Http\Controllers\isEmpty()
I did check the question that had a similar title to mine but that didn't have what I needed.
Here is my code
$orders = Order::all();
if(isEmpty($orders))
{
    echo "Im empty";
    die();
 }else{
    echo "im not empty";
     die();
 }
You should use Model::exists(). It returns true/false and runs a select count(*) from table where query under the hood.
if (Order::exists()) {
    echo "im not empty";
    die();
} else {
    echo "Im empty";
    die();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With