I am using a trait in Laravel Base Controller and when I call any function defined in trait in any child class it throws method not defined exception. The code of Base and child controllers are following. Also is there any way to use common namespaces once in base class and we should not have to call them again in child class.
Base Controller:
namespace App\Http\Controllers\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Traits\ApiResponser;
use Validator;
class UserController extends Controller
{
use ApiResponser;
public function __construct()
{
$this->middleware("auth:api");
}
}
Child Controller:
namespace App\Http\Controllers\User_Disco;
use App\Http\Controllers\User\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UserDiscoController extends UserController
{
public function __construct()
{
parent::__construct();
}
public function some function()
{
$this->methoddefinedintrait();
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Chq84U
via IFTTT
Aucun commentaire:
Enregistrer un commentaire