mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
498 B
PHP
25 lines
498 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Group;
|
|
use App\Models\Post;
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class PostSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
//
|
|
Post::factory(55)->create();
|
|
|
|
foreach (Post::inRandomOrder()->limit(10)->get() as $post) {
|
|
$post->groups()->sync(Group::all()->pluck('id')->toArray());
|
|
}
|
|
}
|
|
}
|