– まずlogin, authから確認
– upgrade後に基本動作から試していく
– packageもlaravelのヴァージョンに依存関係がある為、composer.jsonも必ず確認する(laravel collective)
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
$ php artisan route:list;
https://github.com/laravel-shift/laravel-5.3/blob/master/app/Http/Controllers/Auth/LoginController.php
Authフォルダの下にcontroller fileを追加
LoginController.php
ResetPasswordController.php
RegisterController.php
ForgotPasswordController.php
web.php
Route::auth();
Route::get('/logout', 'Auth\LoginController@logout');
LoginController.php
protected $redirectTo = '/';
web.php
Route::group(['middleware'=>'admin'], function(){
Route::get('/admin', function(){
return view('admin.index');
});
Route::resource('admin/users', 'AdminUsersController',['names'=>[
'index'=>'admin.users.index',
'create'=>'admin.users.create',
'store'=>'admin.users.store',
'edit'=>'admin.users.edit',
]]);
Route::resource('admin/posts', 'AdminPostsController', ['names'=>[
'index'=>'admin.posts.index',
'create'=>'admin.posts.create',
'store'=>'admin.posts.store',
'edit'=>'admin.posts.edit',
]]);
Route::resource('admin/categories', 'AdminCategoriesController', ['names'=>[
'index'=>'admin.categories.index',
'create'=>'admin.categories.create',
'store'=>'admin.categories.store',
'edit'=>'admin.categories.edit',
]]);
Route::resource('admin/media', 'AdminMediasController', ['names'=>[
'index'=>'admin.media.index',
'create'=>'admin.media.create',
'store'=>'admin.media.store',
'edit'=>'admin.media.edit',
]]);
Route::resource('admin/comments', 'PostCommentsController', ['names'=>[
'index'=>'admin.comments.index',
'create'=>'admin.comments.create',
'store'=>'admin.comments.store',
'edit'=>'admin.comments.edit',
]]);
Route::resource('admin/comments/replies', 'CommentRepliesController', ['names'=>[
'index'=>'admin.replies.index',
'create'=>'admin.replies.create',
'store'=>'admin.replies.store',
'edit'=>'admin.replies.edit',
]]);
});
AdminUsersController
lists->pluckに変更
public function create()
{
//
$roles = Role::pluck('name','id')->all();
return view('admin.users.create', compact('roles'));
}
$categories = Category::pluck('name', 'id')->all();
composer.json
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.3.*",
"laravelcollective/html": "5.3.*"
},
Middleware: kernel.php
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'admin' => \App\Http\Middleware\Admin::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
];
$ php composer.phar require cviebrock/eloquent-sluggable:^4.0
$ php artisan vendor:publish –provider=”Cviebrock\EloquentSluggable\ServiceProvider”
フレームワークのアップデートは、アップデートに伴う変更点を一つ一つ潰していくのかと思っていましたが、そうではなく、まずupgradeして、挙動を一つ一つ確認しながらエラーを潰していく。発想が真逆でした。道理で、凄い大変そうにみえたわけだ。。
ただし、マイクロアプリケーションなら比較的すぐ終わりそうですが、大規模アプリケーションだと、テスト工数が結構かかりそうです。