Laravel Route无需方法即可获得控制器的构造

Route::get('customer/{id}', 'Customer@method'); <-- want to call construct not method

class Customer extends Controller
{
    public function __construct(){
        echo 123456;
    }

I'm new in laravel

I try to call __construct from my controller without method, but I got error, is anyone know how to do it?

Try to do like this

  1. Define route

Route::resource('customer/{id}', 'Customer');

  1. In your Customer Controller
use Route;
public function __construct()
{
  $id = Route::current()->getParameter('id');
  dd($id);
}