|
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/ |
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Artisan;
use Database\Seeders\View\Qty_Item_Incoming_Seeder;
use Database\Seeders\View\Qty_POS_Item_Seeder;
use Database\Seeders\View\Item_Master_Seeder;
use Database\Seeders\Common\CommonCodePOSTypeSeeder;
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('pos', function (Blueprint $table) {
$table->id();
$table->string('format', 100);
$table->string('series', 100);
$table->datetime('date_trans');
$table->bigInteger('tenant_id');
$table->bigInteger('user_id');
$table->bigInteger('curr_id');
$table->bigInteger('curr_id_to');
$table->decimal('curr_rate', 18, 4)->default(0);
$table->decimal('qty', 18, 4)->default(0);
$table->decimal('total', 18, 4)->default(0);
$table->decimal('discount', 18, 4)->default(0);
$table->decimal('charge', 18, 4)->default(0);
$table->decimal('vat', 18, 4)->default(0);
$table->string('pos_type', 255);
$table->string('payment_type', 255)->nullable();
$table->bigInteger('payment_id')->nullable();
$table->text('description')->nullable();
$table->timestamps();
});
Schema::create('pos_detail', function (Blueprint $table) {
$table->id();
$table->bigInteger('pos_id');
$table->bigInteger('item_id');
$table->decimal('qty', 18, 4)->default(0);
$table->decimal('price', 18, 4)->default(0);
$table->decimal('discount', 18, 4)->default(0);
$table->text('description')->nullable();
$table->timestamps();
});
Artisan::call('db:seed', [
'--class' => Qty_Item_Incoming_Seeder::class,
]);
Artisan::call('db:seed', [
'--class' => Qty_POS_Item_Seeder::class,
]);
Artisan::call('db:seed', [
'--class' => Item_Master_Seeder::class,
]);
Artisan::call('db:seed', [
'--class' => CommonCodePOSTypeSeeder::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_pos_pos_view', 'web', '$now', '$now'),
('posT_trans_pos_pos_create', 'web', '$now', '$now'),
('posT_trans_pos_pos_edit', 'web', '$now', '$now'),
('posT_trans_pos_pos_delete', 'web', '$now', '$now'),
('posT_trans_pos_pos_print', 'web', '$now', '$now')
;"
);
$admin = User::where('name', 'admin')->first();
$admin->givePermissionTo('posT_trans_pos_pos_view', 'posT_trans_pos_pos_create', 'posT_trans_pos_pos_edit', 'posT_trans_pos_pos_delete', 'posT_trans_pos_pos_print');
$tenant = User::where('model_type', 'App\Models\Master\Tenant')->first();
$tenant->givePermissionTo('posT_trans_pos_pos_view', 'posT_trans_pos_pos_create', 'posT_trans_pos_pos_edit', 'posT_trans_pos_pos_delete', 'posT_trans_pos_pos_print');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pos');
Schema::dropIfExists('pos_detail');
}
};