S
S
semki0962019-04-08 22:34:52
ORM
semki096, 2019-04-08 22:34:52

What is the best way to work with Eloquent - through the creation of a model or through a container, using an example?

I work for Slim. Connected Eloquent. I look at examples of how people work using the known ORM. Some access the database through the container, others through the model

//all products
       $products = $this->container->db->table('products')->get();
       foreach ($products as $product){
           echo $product->name . "</br>";
       }
        
       $products = Product::all();
       foreach ($products as $product){
           echo $product->name . "</br>";
       }

What is the difference. How and when is it best to use these approaches? Or are they identical?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question