0

I generated a model using this command:

php artisan make:model Notification

the model file looks like this :

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Notification
 *
 * @property int $id
 * @property int|null $address_id
 * @property string $business_name
 * @property string $legal_structure
 * @property string|null $siret_number
 * @property string|null $rna_number
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @mixin \Eloquent
 */
class Notification extends Model
{
    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    protected $guarded = ['id'];
    
}

then I used the make migration command to create the model's table in the database but it returns nothing to migrate and it doesn't create any table

CoderTn
  • 985
  • 2
  • 22
  • 49
  • 3
    Instead of doing the command separately, you can generate the migrations when making the model, just pass the `-m` option; `php artisan make:model -m Notification`. For a list of all options, you can check the `getOptions` method on the [ModelMakeCommand](https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/Console/ModelMakeCommand.php) class. – Kim Hallberg Jun 06 '21 at 02:01
  • how to add the model attributes to the table after that ? – CoderTn Jun 06 '21 at 02:05
  • 1
    Everything on how models and migrations work is documented well in the official [Laravel documentation](https://laravel.com/docs/8.x/migrations). With documentation ranging from Laravel v4.2 to v8.x. I recommend reading through it to get a better understanding of the framework. – Kim Hallberg Jun 06 '21 at 02:09

1 Answers1

1

If your application uses Laravel's built in notifications, then you already have a notifications table and migration created from running php artisan notifications:table.

Laravel won't create another migration file for the table if one already exists.

You will need to use a different table name, and I would suggest renaming your Notification model to match whatever table name you choose.

patricus
  • 59,488
  • 15
  • 143
  • 145