I have a many to many relationship between two models:
User
namespace App\Models;
class User extends Model
{
use HasApiTokens, Notifiable,hasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
];
}
Notification
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Notification extends Model
{
/**
* @var array
*/
protected $guarded = ['id'];
use HasFactory;
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
}
I created a factory for each model and a Seeder which calls the two factories in order to create users and attach notifications to each one of them.
NotificationUserSeeder:
<?php
namespace Database\Seeders;
use App\Models\Notification;
use App\Models\User;
use Illuminate\Database\Seeder;
class MockNotificationUser extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
}
}
I am getting this error when running db:seed:
Call to undefined method Illuminate\Notifications\Notification::getConnectionName()