Support the ongoing development of Laravel.io →
Eloquent Architecture
Last updated 1 year ago.
0
Solution

you must use static function for this

public static function getId($name)
{
 ........
}

also you can use dependency injection for controller like this controller

class SiteController{
  protected $model;
  public function __construct(Site $site)
  {
      $this->model = $site;
  }
 public function index()
 {
     $all = $this->model->all();
 }
}
Last updated 1 year ago.
0

So as far as i understood all methods in models should be static?

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2024 Laravel.io - All rights reserved.