Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /home/elvh3918/public_html/tenant/database/migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/elvh3918/public_html/tenant/database/migrations/2025_08_08_062149_create_tenant_table.php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Artisan;
use Database\Seeders\Master\TenantSeeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use App\Models\User;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('tenant', function (Blueprint $table) {
            $table->id();
            $table->string('code', 25);
            $table->string('name', 100);
            $table->string('owner', 50);
            $table->text('address')->nullable();
            $table->string('email', 50);
            $table->string('phone', 50);
            $table->text('map')->nullable();
            $table->text('image')->nullable();
            $table->string('description')->nullable();
            $table->bigInteger('curr_id');
            $table->tinyInteger('is_active')->default(1);
            $table->timestamps();
        });

        Artisan::call('db:seed', [
            '--class' => TenantSeeder::class,
        ]);

        // register permissions
        app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();

        $now = Carbon::now();
        DB::insert(
            "INSERT INTO permissions (name, guard_name, created_at, updated_at) VALUES 
            ('posT_master_tenant_tenant_view', 'web', '$now', '$now'),
            ('posT_master_tenant_tenant_create', 'web', '$now', '$now'),
            ('posT_master_tenant_tenant_edit', 'web', '$now', '$now'),
            ('posT_master_tenant_tenant_delete', 'web', '$now', '$now'),
            ('posT_master_tenant_tenant_print', 'web', '$now', '$now')
            ;"
        );

        $admin = User::where('name', 'admin')->first();
        $admin->givePermissionTo('posT_master_tenant_tenant_view', 'posT_master_tenant_tenant_create', 'posT_master_tenant_tenant_edit', 'posT_master_tenant_tenant_delete', 'posT_master_tenant_tenant_print');
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('tenant');
    }
};

Yohohohohohooho | Sanrei Aya