LoginSignup
5
4

More than 3 years have passed since last update.

[laravel] UserモデルをModelsディレクトリに移動

Last updated at Posted at 2020-07-24

laravel 7.19.1でのやり方です

参考にした記事
【Laravel】モデルのディレクトリ構成変更についてのメモ

参考にさせていただいた内容とほぼ同じですが、バージョンから変更ファイルに多少違いがありましたのでメモ程度ですが紹介します

準備

1.認証を追加

*リファレンスから

$ composer require laravel/ui

$ php artisan ui vue --auth

2.ディレクトリを作成

$ mkdir Models

3.User.phpを移動

$ mv User.php Models

ファイルの修正

User.php
namespace App;
変更
namespace App\Models;
RegisterController.php
use App\User;
変更
use App\Models\User;
auth.php
     'providers' => [
         'users' => [
             'driver' => 'eloquent',
             'model' => App\User::class,
        ↓変更
             'model' => App\Models\User::class,
         ],

UserFactory.php
use App\User;
変更
use App\Models\User;

でいけると思います!

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4