|
7 | 7 | use Illuminate\Database\Eloquent\Model;
|
8 | 8 | use Illuminate\Database\Eloquent\SoftDeletes;
|
9 | 9 | use Illuminate\Database\Schema\Blueprint;
|
| 10 | +use Illuminate\Http\Request; |
| 11 | +use Illuminate\Routing\Controller; |
10 | 12 | use Illuminate\Support\Facades\Route;
|
11 | 13 | use Illuminate\Support\Facades\Schema;
|
12 | 14 | use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles;
|
13 | 15 | use Orchestra\Testbench\TestCase;
|
14 | 16 |
|
| 17 | +class ImplicitController extends Controller |
| 18 | +{ |
| 19 | + /** |
| 20 | + * Display a listing of the resource. |
| 21 | + */ |
| 22 | + public function index() |
| 23 | + { |
| 24 | + // |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Show the form for creating a new resource. |
| 29 | + */ |
| 30 | + public function create() |
| 31 | + { |
| 32 | + // |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Store a newly created resource in storage. |
| 37 | + */ |
| 38 | + public function store(Request $request) |
| 39 | + { |
| 40 | + // |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Display the specified resource. |
| 45 | + */ |
| 46 | + public function show(ImplicitBindingUser $user) |
| 47 | + { |
| 48 | + return $user; |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Show the form for editing the specified resource. |
| 53 | + */ |
| 54 | + public function edit(ImplicitBindingUser $user) |
| 55 | + { |
| 56 | + // |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Update the specified resource in storage. |
| 61 | + */ |
| 62 | + public function update(Request $request, ImplicitBindingUser $user) |
| 63 | + { |
| 64 | + // |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Remove the specified resource from storage. |
| 69 | + */ |
| 70 | + public function destroy(ImplicitBindingUser $user) |
| 71 | + { |
| 72 | + // |
| 73 | + } |
| 74 | +} |
| 75 | + |
15 | 76 | class ImplicitModelRouteBindingTest extends TestCase
|
16 | 77 | {
|
17 | 78 | use InteractsWithPublishedFiles;
|
@@ -141,6 +202,26 @@ public function testSoftDeletedModelsCanBeRetrievedUsingWithTrashedMethod()
|
141 | 202 | ]);
|
142 | 203 | }
|
143 | 204 |
|
| 205 | + public function testSoftDeletedModelsCanBeRetrievedUsingWithTrashedMethodWithSpecificFunction() |
| 206 | + { |
| 207 | + $user = ImplicitBindingUser::create(['name' => 'Dries']); |
| 208 | + |
| 209 | + $user->delete(); |
| 210 | + |
| 211 | + config(['app.key' => str_repeat('a', 32)]); |
| 212 | + |
| 213 | + Route::resource('users', ImplicitController::class) |
| 214 | + ->middleware(['web']) |
| 215 | + ->withTrashed('show'); |
| 216 | + |
| 217 | + $response = $this->getJson("/users/{$user->id}"); |
| 218 | + |
| 219 | + $response->assertJson([ |
| 220 | + 'id' => $user->id, |
| 221 | + 'name' => $user->name, |
| 222 | + ]); |
| 223 | + } |
| 224 | + |
144 | 225 | public function testEnforceScopingImplicitRouteBindings()
|
145 | 226 | {
|
146 | 227 | $user = ImplicitBindingUser::create(['name' => 'Dries']);
|
|
0 commit comments