S
S
semki0962019-03-15 15:32:41
Slim Framework
semki096, 2019-03-15 15:32:41

When is it better to do without a model using the Slim framework and eloquent?

The documentation for Slim in the Eloquent section has an example of using it without creating a model, when we simply get an object from the base in the container, and then pass it to the class we need.

$container[App\WidgetController::class] = function ($c) {
    $view = $c->get('view');
    $table = $c->get('db')->table('table_name');
    return new \App\WidgetController($view, $logger, $table);
};

I also saw examples where a model is created, and through this model we receive data.
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $table = 'users';
}

The question is - what is the difference, and in which cases which option should be used?

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