Constructors do not return values, their only purpose is to instantiate class instances.
If you want to fetch data and use it in your class, you can do something like:
class AdminController extends Controller
{
private $notifications;
public function __construct()
{
$this->notifications = Notification::where('read_status', 0)->get();
}
}
or
class AdminController extends Controller
{
private $notifications;
public function __construct()
{
$this->loadUnreadNotifications();
}
private function loadUnreadNotifications()
{
$this->notifications = Notification::where('read_status', 0)->get();
}
}
After which you can use $this->notifications in your other controller methods.