How to assign variable as a value to another variable in php laravel class

Viewed 33

I am trying to assign a variable to another variable as a default value in the BaseController in laravel, and if I did not override the variable in the child class, the variable will take the assigned variable as a default value.

    public $route_view_name;
    public $route_name = $this->route_view_name;
    public $view_name = $this->route_view_name;
    
    public $route_show = $this->route_name . '.show';
    public $route_index = $this->route_name . '.index';
    public $route_create = $this->route_name . '.create';
    public $route_edit = $this->route_name . '.edit';
    
    public $view_show = $this->view_name . '.show';
    public $view_index = $this->view_name . '.index';
    public $view_create = $this->view_name . '.create';
    public $view_edit = $this->view_name . '.edit';

it does not work and I know that it's wrong but I want to know what is the best alternative that I can use that helps me when I override these variables

0 Answers
Related