File: /home/eslinced-103/brise-edu.or.kr/database/seeders/TenantDatabaseSeeder.php
<?php
namespace Database\Seeders;
use App\Models\Post;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
class TenantDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
if(config('amuz.use_tenant_preset',false) === true) {
if(Post::all()->count() < 1){
Post::create([
'user_id' => 1,
'title' => 'Welcome',
'body' => "Try creating another blog post here, then register as another tenant on your central domain. You'll see the data separation in practice.",
]);
Post::create([
'user_id' => 1,
'title' => 'README!',
'body' => "Be sure to check the README.md file. It explains how things are structured, why they're structured that way and how to make the most out of this boilerplate.",
]);
Post::create([
'user_id' => 1,
'title' => '🚀 Ship fast',
'body' => "As always, don't forget to ship fast 😎. We hope this boilerplate saves you a lot of development time and lets you get to production much faster.",
]);
}
}
$packages = $this->getAmuzPackages();
foreach($packages as $package){
$path = base_path(sprintf('AmuzPackages/%s/Database/Seeders/Tenant/TenantDatabaseSeeder.php',$package));
if(file_exists($path)){
$class = new (sprintf('AmuzPackages\\%s\\Database\\Seeders\\Tenant\\TenantDatabaseSeeder',$package))();
$class->run();
}
}
}
private function getAmuzPackages(): array
{
return Storage::disk('package')->directories();
}
}