Model 생성하기

model, migration, controller
1php artisan make:model notice -mrc

Model 설정보기

1$ php artisan model:show notice
1# Generate a model and a FlightFactory class...
2php artisan make:model Flight --factory
3php artisan make:model Flight -f
4 
5# Generate a model and a FlightSeeder class...
6php artisan make:model Flight --seed
7php artisan make:model Flight -s
8 
9# Generate a model and a FlightController class...
10php artisan make:model Flight --controller
11php artisan make:model Flight -c
12 
13# Generate a model, FlightController resource class, and form request classes...
14php artisan make:model Flight --controller --resource --requests
15php artisan make:model Flight -crR
16 
17# Generate a model and a FlightPolicy class...
18php artisan make:model Flight --policy
19 
20# Generate a model and a migration, factory, seeder, and controller...
21php artisan make:model Flight -mfsc
22 
23# Shortcut to generate a model, migration, factory, seeder, policy, controller, and form requests...
24php artisan make:model Flight --all
25 
26# Generate a pivot model...
27php artisan make:model Member --pivot
1namespace App\Models;
2 
3use App\Events\NoticeCreated;
4use Illuminate\Database\Eloquent\Model;
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6 
7class Notice extends Model
8{
9 
10 use HasFactory;
11 
12 protected $fillable = [
13 'subject',
14 'content',
15 'name',
16 'email',
17 'user_id',
18 'created_at',
19 'updated_at',
20 ];
21 
22 protected $hidden = [
23 'password',
24 'remember_token',
25 'permissions',
26 ];
27 
28 protected $dispatchesEvents = [
29 'created' => NoticeCreated::class,
30 ];
31 
32 public function user()
33 {
34 return $this->belongsTo(User::class);
35 }
36}