Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\DB; r..

Decoded Output download

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // This updates the 'type' field for images, uploaded as shelf cover images,
        // to be cover_bookshelf instead of cover_book.
        // This does not fix their paths, since fixing that requires a more complicated operation,
        // but their path does not affect functionality at time of this fix.

        $shelfImageIds = DB::table('bookshelves')
            ->whereNotNull('image_id')
            ->pluck('image_id')
            ->values()->all();

        if (count($shelfImageIds) > 0) {
            DB::table('images')
                ->where('type', '=', 'cover_book')
                ->whereIn('id', $shelfImageIds)
                ->update(['type' => 'cover_bookshelf']);
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('images')
            ->where('type', '=', 'cover_bookshelf')
            ->update(['type' => 'cover_book']);
    }
};
 ?>

Did this file decode correctly?

Original Code

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // This updates the 'type' field for images, uploaded as shelf cover images,
        // to be cover_bookshelf instead of cover_book.
        // This does not fix their paths, since fixing that requires a more complicated operation,
        // but their path does not affect functionality at time of this fix.

        $shelfImageIds = DB::table('bookshelves')
            ->whereNotNull('image_id')
            ->pluck('image_id')
            ->values()->all();

        if (count($shelfImageIds) > 0) {
            DB::table('images')
                ->where('type', '=', 'cover_book')
                ->whereIn('id', $shelfImageIds)
                ->update(['type' => 'cover_bookshelf']);
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('images')
            ->where('type', '=', 'cover_bookshelf')
            ->update(['type' => 'cover_book']);
    }
};

Function Calls

None

Variables

None

Stats

MD5 4554fcf1d1405494bb8e3d6956e21824
Eval Count 0
Decode Time 91 ms