Here is my Controller.php that all the other Controller extend from. I was hoping to do that
<?php
namespace App\Http\Controllers;
use App\User;
use App;
use URL;
use App\City;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController {
use DispatchesCommands, ValidatesRequests;
}
But looks like it doesn't work. I need to call use App\User in each controller that uses it even if it is extending the basecontroller.
This doesn't work:
<?php
namespace App\Http\Controllers;
class HomeController extends Controller { .... }
But this does:
namespace App\Http\Controllers;
use App\User;
use App;
use URL;
use App\City;
class HomeController extends Controller { .... }
Is this normal? Does it has to be that painful :-) There are some Classes used in every Controller, it is just a bit surprising I need to call them every time.
Note: I am migrating from 4.2 and want to go with namespaces Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire