In my general controller GeneralController:
use App\Http\Controllers\Controller;
class GeneralController extends Controller
{
protected $onLine = null;
public function __construct(Request $request)
{
$this->onLine = OnLine::domain($request->domain)->first();
}
}
In my other controller, extends GeneralController:
use App\Http\Controllers\OnLine\ItemController;
class ItemController extends GeneralController
{
public function getItem(Request $request)
{
dd($this->onLine); // but returns null :(
}
}
I already checked, that OnLine::domain($request->domain)->first();
returns data, which it does.
The parent constructor will help you!!
class ItemController extends GeneralController
{
public function __construct()
{
parent::__construct();
....
}
}