I need to change the table name during authorization, but I get the error Accessing static property App \ Http \ Controllers \ AuthController :: $ table_name as non static

AuthController.php

public static $table_name = 'server_1_users'; public function findOrNewUser($info) { $user = new User($this->table_name); $user = User::where('steam_id', $info->steamID64)->first(); } 

User.php public $ table;

 public function __construct() { $this->table = AuthController::$table_name; } 
  • one
    Well, in new User($this->table_name); Why is $this used if the property is static? - u_mulder

1 answer 1

AuthController.php

 public static $table_name = 'server_1_users'; public function findOrNewUser($info) { $user = new User(self::table_name); $user = User::where('steam_id', $info->steamID64)->first(); } 

Why change the name of the table during authorization? I would advise to review the logic of your application.