input('migration_key'); // Assuming the key is passed as a GET parameter if (!$key) { return response()->json(['error' => 'Migration key is missing'], 401); } $storedKey = Storage::get('migration_key.txt'); // Retrieve the stored key from the file if ($key !== $storedKey) { return response()->json(['error' => 'Invalid migration key'], 401); } Storage::delete('migration_key.txt'); return $next($request); } }