|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/lecturebazaar.com/database/seeders/ |
Upload File : |
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class makeFakeFilters extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$categories = App\Models\Category::whereNotNull('parent_id')->get();
foreach ($categories as $category) {
foreach (range(1, 4) as $index) {
DB::table('filters')->insert([
'category_id' => $category->id,
'title' => Str::random(5) . ' ' . Str::random(6)
]);
}
}
$filters = App\Models\Filter::get();
foreach ($filters as $filter) {
foreach (range(1, random_int(3, 6)) as $index) {
DB::table('filter_options')->insert([
'filter_id' => $filter->id,
'title' => Str::random(3) . ' ' . Str::random(4)
]);
}
}
}
}