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 namespace Maatwebsite\Excel\Tests\Concerns; use Illuminate\Database\Eloquent\Builde..
Decoded Output download
<?php
namespace Maatwebsite\Excel\Tests\Concerns; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Maatwebsite\Excel\Concerns\Importable; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithBatchInserts; use Maatwebsite\Excel\Concerns\WithUpsertColumns; use Maatwebsite\Excel\Concerns\WithUpserts; use Maatwebsite\Excel\Tests\Data\Stubs\Database\User; use Maatwebsite\Excel\Tests\TestCase; class WithUpsertsTest extends TestCase { protected function setUp() : void { if (!method_exists(Builder::class, "upsert")) { $this->markTestSkipped("The upsert feature is available on Laravel 8.10+"); } parent::setUp(); $this->loadLaravelMigrations(array("--database" => "testing")); } public function test_can_upsert_models_in_batches() { User::create(array("name" => "Funny Banana", "email" => "[email protected]", "password" => "password")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithBatchInserts, WithUpserts { use Importable; public function model(array $row) { return new User(array("name" => $row[0], "email" => $row[1], "password" => "secret")); } public function uniqueBy() { return "email"; } public function batchSize() : int { return 2; } }; $import->import("import-users.xlsx"); $this->assertCount(1, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("users", array("name" => "Patrick Brouwers", "email" => "[email protected]", "password" => "secret")); $this->assertDatabaseHas("users", array("name" => "Taylor Otwell", "email" => "[email protected]", "password" => "secret")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_rows() { User::create(array("name" => "Funny Potato", "email" => "[email protected]", "password" => "password")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithUpserts { use Importable; public function model(array $row) { return new User(array("name" => $row[0], "email" => $row[1], "password" => "secret")); } public function uniqueBy() { return "email"; } }; $import->import("import-users.xlsx"); $this->assertCount(2, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("users", array("name" => "Patrick Brouwers", "email" => "[email protected]", "password" => "secret")); $this->assertDatabaseHas("users", array("name" => "Taylor Otwell", "email" => "[email protected]", "password" => "secret")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_batches_with_defined_upsert_columns() { User::create(array("name" => "Funny Banana", "email" => "[email protected]", "password" => "password")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithBatchInserts, WithUpserts, WithUpsertColumns { use Importable; public function model(array $row) { return new User(array("name" => $row[0], "email" => $row[1], "password" => "secret")); } public function uniqueBy() { return "email"; } public function upsertColumns() { return array("name"); } public function batchSize() : int { return 2; } }; $import->import("import-users.xlsx"); $this->assertCount(1, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("users", array("name" => "Patrick Brouwers", "email" => "[email protected]", "password" => "password")); $this->assertDatabaseHas("users", array("name" => "Taylor Otwell", "email" => "[email protected]", "password" => "secret")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_rows_with_defined_upsert_columns() { User::create(array("name" => "Funny Potato", "email" => "[email protected]", "password" => "password")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithUpserts, WithUpsertColumns { use Importable; public function model(array $row) { return new User(array("name" => $row[0], "email" => $row[1], "password" => "secret")); } public function uniqueBy() { return "email"; } public function upsertColumns() { return array("name"); } }; $import->import("import-users.xlsx"); $this->assertCount(2, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("users", array("name" => "Patrick Brouwers", "email" => "[email protected]", "password" => "password")); $this->assertDatabaseHas("users", array("name" => "Taylor Otwell", "email" => "[email protected]", "password" => "secret")); $this->assertEquals(2, User::count()); } } ?>
Did this file decode correctly?
Original Code
<?php
namespace Maatwebsite\Excel\Tests\Concerns; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Maatwebsite\Excel\Concerns\Importable; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithBatchInserts; use Maatwebsite\Excel\Concerns\WithUpsertColumns; use Maatwebsite\Excel\Concerns\WithUpserts; use Maatwebsite\Excel\Tests\Data\Stubs\Database\User; use Maatwebsite\Excel\Tests\TestCase; class WithUpsertsTest extends TestCase { protected function setUp() : void { if (!method_exists(Builder::class, "\165\x70\x73\145\x72\164")) { $this->markTestSkipped("\124\x68\145\40\165\160\x73\145\162\164\x20\146\x65\141\x74\165\x72\x65\x20\x69\x73\40\x61\x76\x61\151\154\141\142\154\x65\40\157\156\x20\x4c\141\x72\141\166\x65\x6c\x20\x38\56\x31\60\53"); } parent::setUp(); $this->loadLaravelMigrations(array("\x2d\x2d\144\x61\x74\141\x62\141\x73\145" => "\164\145\x73\x74\x69\x6e\147")); } public function test_can_upsert_models_in_batches() { User::create(array("\x6e\x61\155\x65" => "\106\x75\x6e\x6e\171\x20\x42\x61\x6e\141\156\x61", "\x65\155\141\151\x6c" => "\160\141\x74\162\x69\x63\153\x40\155\141\141\164\167\145\x62\163\x69\164\145\56\156\154", "\160\141\x73\163\167\x6f\162\x64" => "\x70\x61\x73\x73\167\157\x72\144")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithBatchInserts, WithUpserts { use Importable; public function model(array $row) { return new User(array("\156\x61\155\145" => $row[0], "\145\155\x61\x69\154" => $row[1], "\x70\x61\163\163\167\x6f\162\144" => "\163\145\143\x72\145\164")); } public function uniqueBy() { return "\x65\x6d\x61\x69\x6c"; } public function batchSize() : int { return 2; } }; $import->import("\x69\x6d\x70\x6f\x72\x74\x2d\x75\x73\145\x72\x73\56\170\154\x73\170"); $this->assertCount(1, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("\x75\x73\x65\x72\x73", array("\x6e\x61\155\x65" => "\x50\141\x74\x72\151\143\x6b\40\x42\162\x6f\x75\x77\145\162\163", "\145\x6d\141\x69\154" => "\x70\x61\164\x72\x69\x63\153\x40\x6d\141\141\x74\167\145\142\163\151\x74\145\x2e\x6e\x6c", "\160\x61\163\163\167\x6f\x72\144" => "\x73\145\x63\162\x65\x74")); $this->assertDatabaseHas("\x75\163\145\x72\163", array("\156\x61\x6d\145" => "\124\141\x79\154\157\162\x20\x4f\164\x77\x65\x6c\154", "\x65\x6d\141\x69\x6c" => "\x74\x61\171\154\x6f\x72\100\x6c\141\162\x61\x76\145\154\x2e\143\x6f\155", "\x70\x61\x73\163\167\157\162\144" => "\x73\145\x63\x72\145\164")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_rows() { User::create(array("\156\141\x6d\x65" => "\106\165\156\x6e\x79\40\120\x6f\164\x61\164\157", "\x65\x6d\141\x69\x6c" => "\x70\x61\x74\162\x69\x63\x6b\x40\155\141\141\x74\x77\145\142\x73\x69\164\145\56\x6e\x6c", "\x70\x61\x73\x73\x77\x6f\162\144" => "\x70\141\x73\x73\x77\x6f\x72\144")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithUpserts { use Importable; public function model(array $row) { return new User(array("\156\x61\155\x65" => $row[0], "\145\x6d\x61\151\154" => $row[1], "\x70\x61\163\x73\x77\157\162\x64" => "\163\x65\x63\x72\x65\x74")); } public function uniqueBy() { return "\145\155\141\x69\x6c"; } }; $import->import("\151\x6d\160\x6f\162\164\x2d\165\x73\145\162\163\56\170\154\x73\170"); $this->assertCount(2, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("\165\163\145\162\163", array("\x6e\x61\x6d\x65" => "\x50\141\x74\162\151\143\153\x20\x42\162\x6f\165\167\x65\162\163", "\145\155\x61\x69\154" => "\x70\141\x74\162\x69\x63\x6b\x40\155\x61\x61\164\167\145\142\x73\151\164\x65\56\x6e\154", "\x70\141\x73\x73\x77\x6f\162\x64" => "\x73\x65\143\x72\145\x74")); $this->assertDatabaseHas("\165\163\x65\162\163", array("\x6e\141\x6d\145" => "\124\141\171\x6c\157\x72\40\117\164\x77\145\x6c\x6c", "\x65\155\141\x69\154" => "\x74\141\x79\154\157\162\100\154\x61\162\x61\x76\x65\154\56\x63\x6f\x6d", "\160\141\x73\x73\167\x6f\162\x64" => "\x73\145\x63\x72\145\164")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_batches_with_defined_upsert_columns() { User::create(array("\156\x61\155\x65" => "\106\165\156\156\x79\40\102\141\x6e\141\156\x61", "\x65\155\x61\151\x6c" => "\x70\x61\x74\x72\151\143\153\x40\x6d\141\x61\164\167\x65\142\163\151\x74\x65\x2e\x6e\x6c", "\160\x61\163\163\x77\x6f\162\144" => "\160\x61\163\163\x77\x6f\162\144")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithBatchInserts, WithUpserts, WithUpsertColumns { use Importable; public function model(array $row) { return new User(array("\156\141\155\x65" => $row[0], "\145\x6d\141\151\154" => $row[1], "\160\141\163\x73\x77\157\x72\144" => "\163\145\143\x72\x65\x74")); } public function uniqueBy() { return "\145\155\141\151\154"; } public function upsertColumns() { return array("\x6e\141\x6d\x65"); } public function batchSize() : int { return 2; } }; $import->import("\151\155\160\x6f\x72\x74\55\x75\163\x65\x72\x73\56\x78\154\163\x78"); $this->assertCount(1, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("\165\163\x65\162\x73", array("\x6e\141\x6d\145" => "\x50\141\x74\162\x69\143\153\x20\x42\x72\157\165\167\x65\x72\x73", "\145\x6d\x61\x69\x6c" => "\x70\141\x74\x72\x69\143\153\100\155\141\141\x74\x77\145\142\x73\x69\x74\x65\x2e\x6e\154", "\x70\x61\163\163\x77\157\162\x64" => "\x70\141\x73\163\167\x6f\x72\144")); $this->assertDatabaseHas("\x75\x73\x65\x72\x73", array("\156\x61\x6d\x65" => "\x54\141\171\154\157\162\40\117\164\167\145\x6c\154", "\145\155\x61\151\x6c" => "\x74\141\x79\x6c\x6f\x72\x40\154\x61\162\x61\x76\x65\x6c\x2e\143\x6f\x6d", "\x70\x61\163\x73\x77\157\x72\x64" => "\163\145\x63\162\145\x74")); $this->assertEquals(2, User::count()); } public function test_can_upsert_models_in_rows_with_defined_upsert_columns() { User::create(array("\x6e\141\155\145" => "\x46\165\x6e\156\x79\x20\x50\157\x74\x61\x74\x6f", "\x65\x6d\x61\x69\x6c" => "\x70\141\x74\162\x69\x63\x6b\100\155\141\141\164\167\145\x62\x73\151\x74\145\x2e\x6e\x6c", "\x70\x61\x73\163\x77\157\x72\x64" => "\160\x61\163\163\167\157\162\144")); DB::connection()->enableQueryLog(); $import = new class implements ToModel, WithUpserts, WithUpsertColumns { use Importable; public function model(array $row) { return new User(array("\156\x61\x6d\145" => $row[0], "\145\155\141\x69\154" => $row[1], "\x70\141\x73\x73\167\157\x72\144" => "\163\145\143\162\145\x74")); } public function uniqueBy() { return "\145\155\141\x69\x6c"; } public function upsertColumns() { return array("\x6e\141\x6d\x65"); } }; $import->import("\151\x6d\160\157\x72\x74\x2d\165\x73\x65\162\163\56\170\154\163\170"); $this->assertCount(2, DB::getQueryLog()); DB::connection()->disableQueryLog(); $this->assertDatabaseHas("\x75\163\145\162\x73", array("\x6e\141\x6d\x65" => "\x50\141\164\162\151\x63\x6b\40\102\x72\157\x75\x77\145\162\163", "\145\x6d\141\x69\x6c" => "\x70\x61\x74\x72\x69\x63\x6b\100\x6d\x61\141\164\167\x65\x62\163\151\164\145\56\x6e\154", "\160\x61\163\163\x77\157\162\x64" => "\160\141\x73\x73\167\157\162\144")); $this->assertDatabaseHas("\x75\x73\145\x72\163", array("\x6e\141\155\x65" => "\124\x61\171\x6c\157\x72\40\117\164\167\145\x6c\x6c", "\145\x6d\141\151\x6c" => "\x74\141\x79\x6c\157\x72\x40\154\x61\x72\x61\166\x65\x6c\56\x63\157\x6d", "\160\141\x73\x73\167\157\x72\x64" => "\163\145\x63\x72\x65\x74")); $this->assertEquals(2, User::count()); } }
Function Calls
None |
Stats
MD5 | 6bf1003c0e93ae0d16e153310f46b6ef |
Eval Count | 0 |
Decode Time | 117 ms |