Skip to content

Commit

Permalink
Revert "[10.x] Add string capability to withTrashed method (#46356)" (
Browse files Browse the repository at this point in the history
#46360)

This reverts commit 9a0aa69.
  • Loading branch information
taylorotwell committed Mar 5, 2023
1 parent 9a0aa69 commit 1ef0471
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 87 deletions.
8 changes: 2 additions & 6 deletions src/Illuminate/Routing/PendingResourceRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,11 @@ public function scoped(array $fields = [])
/**
* Define which routes should allow "trashed" models to be retrieved when resolving implicit model bindings.
*
* @param array|string $methods
* @param array $methods
* @return \Illuminate\Routing\PendingResourceRegistration
*/
public function withTrashed(array|string $methods = [])
public function withTrashed(array $methods = [])
{
if (is_string($methods)) {
$methods = (array) $methods;
}

$this->options['trashed'] = $methods;

return $this;
Expand Down
81 changes: 0 additions & 81 deletions tests/Integration/Routing/ImplicitModelRouteBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles;
use Orchestra\Testbench\TestCase;

class ImplicitController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*/
public function show(ImplicitBindingUser $user)
{
return $user;
}

/**
* Show the form for editing the specified resource.
*/
public function edit(ImplicitBindingUser $user)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, ImplicitBindingUser $user)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(ImplicitBindingUser $user)
{
//
}
}

class ImplicitModelRouteBindingTest extends TestCase
{
use InteractsWithPublishedFiles;
Expand Down Expand Up @@ -202,26 +141,6 @@ public function testSoftDeletedModelsCanBeRetrievedUsingWithTrashedMethod()
]);
}

public function testSoftDeletedModelsCanBeRetrievedUsingWithTrashedMethodWithSpecificFunction()
{
$user = ImplicitBindingUser::create(['name' => 'Dries']);

$user->delete();

config(['app.key' => str_repeat('a', 32)]);

Route::resource('users', ImplicitController::class)
->middleware(['web'])
->withTrashed('show');

$response = $this->getJson("/users/{$user->id}");

$response->assertJson([
'id' => $user->id,
'name' => $user->name,
]);
}

public function testEnforceScopingImplicitRouteBindings()
{
$user = ImplicitBindingUser::create(['name' => 'Dries']);
Expand Down

0 comments on commit 1ef0471

Please sign in to comment.