You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
820 B

  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Models\Collection;
  4. use Closure;
  5. use Illuminate\Http\Request;
  6. class BindCollectionModelMiddleware
  7. {
  8. /**
  9. * Handle an incoming request.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
  13. * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
  14. */
  15. public function handle(Request $request, Closure $next)
  16. {
  17. if ($request->route()->action['as'] == 'api.file.store') {
  18. app()->bind('collection',function() use ($request)
  19. {
  20. return Collection::where('name',$request->route('collections_name'))->get();
  21. });
  22. }
  23. return $next($request);
  24. }
  25. }