Randy_Johnson
3 months ago
291
4
General

Controller Inheritence in Laravel?

Posted 3 months ago by Randy_Johnson

Sorry guys, running in one problem to another, but am just wondering how do I pass variable. I assumed it would be something as simple as this.

class UserController extends Controller { private $table; private $view;

public function __construct() {
    $this->middleware('auth');
    $this->$table = "users";
    $this->view ="admin/user/read";
}

public function create() {

}

public function read() {
    $data = DB::table($this->table)->get();
    return view($this->view, [$this->table => $data]);
}

public function readSingle() {}

public function update() {}

public function delete($slug)
{

}

}

Please sign in or create an account to participate in this conversation.