Failed to save the file to the "xx" directory.

Failed to save the file to the "ll" directory.

Failed to save the file to the "mm" directory.

Failed to save the file to the "wp" directory.

403WebShell
403Webshell
Server IP : 66.29.132.124  /  Your IP : 18.222.182.226
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/book24.ng/database/migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/book24.ng/database/migrations/2019_05_13_111553_update_status_transfers_table.php
<?php

use Bavix\Wallet\Models\Transfer;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class UpdateStatusTransfersTable extends Migration
{

    /**
     * @return string
     */
    protected function table(): string
    {
        return (new Transfer())->getTable();
    }

    /**
     * @return void
     */
    public function up(): void
    {
        $enums = [
            Transfer::STATUS_TRANSFER,
            Transfer::STATUS_PAID,
            Transfer::STATUS_REFUND,
            Transfer::STATUS_GIFT,
        ];

        if (DB::connection() instanceof MySqlConnection) {
            $table = DB::getTablePrefix() . $this->table();
            $enumString = implode('\', \'', $enums);
            $default = Transfer::STATUS_TRANSFER;
            DB::statement("ALTER TABLE $table CHANGE COLUMN status status ENUM('$enumString') NOT NULL DEFAULT '$default'");
            DB::statement("ALTER TABLE $table CHANGE COLUMN status_last status_last ENUM('$enumString') NULL");
            return;
        }

        if (DB::connection() instanceof PostgresConnection) {
            $this->alterEnum(DB::getTablePrefix() . $this->table(), 'status', $enums);
            $this->alterEnum(DB::getTablePrefix() . $this->table(), 'status_last', $enums);
            return;
        }

        Schema::table($this->table(), function (Blueprint $table) use ($enums) {
            $table->string('status')
                ->default(Transfer::STATUS_TRANSFER)
                ->change();

            $table->string('status_last')
                ->nullable()
                ->change();
        });
    }

    /**
     * @return void
     */
    public function down(): void
    {
        DB::table($this->table())
            ->where('status', Transfer::STATUS_TRANSFER)
            ->update(['status' => Transfer::STATUS_PAID]);

        DB::table($this->table())
            ->where('status_last', Transfer::STATUS_TRANSFER)
            ->update(['status_last' => Transfer::STATUS_PAID]);

        $enums = [
            Transfer::STATUS_PAID,
            Transfer::STATUS_REFUND,
            Transfer::STATUS_GIFT,
        ];

        if (DB::connection() instanceof MySqlConnection) {
            $table = DB::getTablePrefix() . $this->table();
            $enumString = implode('\', \'', $enums);
            $default = Transfer::STATUS_PAID;
            DB::statement("ALTER TABLE $table CHANGE COLUMN status status ENUM('$enumString') NOT NULL DEFAULT '$default'");
            DB::statement("ALTER TABLE $table CHANGE COLUMN status_last status_last ENUM('$enumString') NULL");
            return;
        }

        if (DB::connection() instanceof PostgresConnection) {
            $this->alterEnum(DB::getTablePrefix() . $this->table(), 'status', $enums);
            $this->alterEnum(DB::getTablePrefix() . $this->table(), 'status_last', $enums);
            return;
        }

        Schema::table($this->table(), function (Blueprint $table) use ($enums) {
            $table->string('status')
                ->default(Transfer::STATUS_PAID)
                ->change();

            $table->string('status_last')
                ->nullable()
                ->change();
        });
    }

    /**
     * Alter an enum field constraints
     * @param $table
     * @param $field
     * @param array $options
     */
    protected function alterEnum($table, $field, array $options): void
    {
        $check = "${table}_${field}_check";

        $enumList = [];

        foreach ($options as $option) {
            $enumList[] = sprintf("'%s'::CHARACTER VARYING", $option);
        }

        $enumString = implode(', ', $enumList);

        DB::transaction(function () use ($table, $field, $check, $options, $enumString) {
            DB::statement(sprintf('ALTER TABLE %s DROP CONSTRAINT %s;', $table, $check));
            DB::statement(sprintf('ALTER TABLE %s ADD CONSTRAINT %s CHECK (%s::TEXT = ANY (ARRAY[%s]::TEXT[]))', $table, $check, $field, $enumString));
        });
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit