Support the ongoing development of Laravel.io →
Configuration Eloquent Architecture

Ahoi,

want to use static methods and public method (of Instance) from a Model.

have a controller :

class Company extends BaseController
{
    private $model;
    public function __construct(){
        $this->model = new CompanyModel();
    }
    public function index(){
        $doSomething = $this->model->doSomething();
        $doStatic         = CompanyModel::doStatic();
    }
}

have a model:

class CompanyModel extends Eloquent
{
    private $company;
    public function __construct(){
        $this->company = null;
    }
    public function doSomething(){
        //code;
    }
    public static function doStatic(){
        //code;
    }
}

Is this the way of best practice to work with MVC in Laravel?

Sorry for my bad english

Last updated 3 years ago.
0

Eloquent models have a magic static call built in to handle dynamic static calls to model methods, so you can still call CompanyModel::doSomething() and the __callStatic() method within Eloquent will route your request correctly - this means its not necessary to define your model methods as static.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

chrobaks chrobaks Joined 1 Jun 2015

Moderators

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

Your logo here?

Laravel.io

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

© 2025 Laravel.io - All rights reserved.