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_09_151008_create_price_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\Trans\PriceSeeder;
use Database\Seeders\View\Price_Item_Seeder;
use Database\Seeders\Common\CommonCodeTransTypeSeeder;
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('price', function (Blueprint $table) {
            $table->id();
            $table->datetime('date_trans');
            $table->bigInteger('item_id');
            $table->bigInteger('tenant_id');
            $table->bigInteger('curr_id');
            $table->bigInteger('curr_id_to');
            $table->decimal('curr_rate', 18, 4)->default(0);
            $table->decimal('price', 18, 4)->default(0);
            $table->bigInteger('user_id');
            $table->timestamps();
        });

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

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

        Artisan::call('db:seed', [
            '--class' => CommonCodeTransTypeSeeder::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_trans_price_price_view', 'web', '$now', '$now'),
            ('posT_trans_price_price_create', 'web', '$now', '$now'),
            ('posT_trans_price_price_edit', 'web', '$now', '$now'),
            ('posT_trans_price_price_delete', 'web', '$now', '$now'),
            ('posT_trans_price_price_print', 'web', '$now', '$now')
            ;"
        ); 

        $admin = User::where('name', 'admin')->first();
        $admin->givePermissionTo('posT_trans_price_price_view', 'posT_trans_price_price_create', 'posT_trans_price_price_edit', 'posT_trans_price_price_delete', 'posT_trans_price_price_print');
    }

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

Yohohohohohooho | Sanrei Aya