KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/lecturebazaar.com/database/seeders/makeFakeCategories.php
<?php
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Faker\Factory as Faker;
use \Illuminate\Support\Str;

class makeFakeCategories extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker::create();

        // make organization
        foreach (range(1, 10) as $index) {
            DB::table('categories')->insert([
                'parent_id' => null,
                'title' => Str::random(10) . ' ' . Str::random(6)
            ]);
        }

        $categories = App\Models\Category::whereNull('parent_id')->get();

        foreach ($categories as $category) {
            foreach (range(1, random_int(2, 6)) as $index) {
                DB::table('categories')->insert([
                    'parent_id' => $category->id,
                    'title' => Str::random(5) . ' ' . Str::random(6)
                ]);
            }
        }
    }
}

Anon7 - 2021