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/seeders/View/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/elvh3918/public_html/tenant/database/seeders/View/Item_Master_Seeder.php
<?php

namespace Database\Seeders\View;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class Item_Master_Seeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        DB::unprepared('DROP VIEW IF EXISTS vw_item_master');
        DB::unprepared(
            "CREATE VIEW vw_item_master AS
            SELECT
                A.id AS tenant_id, A.code AS tenant_code, A.name AS tenant_name, B.item_id, C.type AS item_type, B.item_name, C.photo AS item_photo, C.description AS item_description, C.is_active AS item_is_active, B.curr_id, B.curr_id_to, B.curr_rate, B.price, IFNULL(SUM(D.qty), 0) AS qty_incoming, IFNULL(SUM(E.qty), 0) AS qty_pos, IFNULL(SUM(D.qty), 0) - IFNULL(SUM(E.qty), 0) AS stock, MAX(D.date_trans) AS last_incoming, MAX(E.date_trans) AS last_pos, A.created_at, A.updated_at
            FROM
                tenant AS A
            INNER JOIN
                vw_price_item AS B ON A.id = B.tenant_id
            LEFT OUTER JOIN
                items AS C ON B.item_id = C.id
            LEFT OUTER JOIN
                vw_qty_incoming_item AS D ON C.id = D.item_id AND A.id = D.tenant_id
            LEFT OUTER JOIN
                vw_qty_pos_item AS E ON C.id = E.item_id AND A.id = E.tenant_id
            GROUP BY A.id, A.code, A.name, B.item_id, C.type, B.item_name, C.photo, C.description, C.is_active, B.curr_id, B.curr_id_to, B.curr_rate, B.price, A.created_at, A.updated_at
            ORDER BY A.id, C.id
            ;
        ");
    }
}

Yohohohohohooho | Sanrei Aya