Why is lumen/laravel throwing error "Too few arguments passed" when using find/findmany?

Related searches

I have an array of ids I want to use to get matching records from a table. Code looks like this:

$res = Extensiontables_Registry::findmany($ids[0])->get();

The full context looks like this:

  public function getData(Request $request){
    $ad_groupsOfUser = $this->getRoles($request);
    $ids = $ad_groupsOfUser->pluck('id');

    $res = Extensiontables_Registry::findmany($ids[0])->get();

    return response()->json($res, 200);
  }

  public function getRoles(Request $request)
  {
    $ad_groups = Ad_user::find($request->decodedToken->user_id)->ad_groups()->get();

    //return response()->json($roles, 200);
    return $ad_groups;
  }

$ids definitely is an array and contains values, I've debugged it. But why isn't it working with find/findmany? This is the full error I get:

 (1/1) ArgumentCountError

Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in E:\aether-backend\app\Http\Controllers\UserController.php on line 49 and at least 1 expected

Once you use find it fetches the data for you. get() is used after a where clause

Model::find();

Model::where(['key' , 1])->get();

Validation - Lumen, If the validation rules pass, your code will keep executing normally; however, if validation fails, an exception will be thrown and the proper error response will� I'm using this library for formRequest feature in my Lumen application. I had installed and configured as mentioned in docs but there seems to be somewhere I might be missing or issue in library. I had installed and configured as mentioned in docs but there seems to be somewhere I might be missing or issue in library.

Use whereIn() method: check here

$res = Extensiontables_Registry::whereIn('id',$ids)->get(); //$ids = [1,2,3,...]

Why is lumen/laravel throwing error "Too few , Once you use find it fetches the data for you. get() is used after a where clause. Model::find(); Model::where(['key' , 1])->get();. The Lumen logging facilities provide a simple layer on top of the powerful Monolog library. By default, Lumen is configured to create a single log file for your application which is stored in the storage/logs directory.

You can use find in place of findMany.

Since you trying to fetch one data. Good approach is to use whereIn method.

public function getData(Request $request){
    $adGroupsOfUser = $this->getRoles($request);
    $ids = $adGroupsOfUser->pluck('id');

    $response = Extensiontables_Registry::whereIn($ids->toArray())->get();

    return response()->json($response, 200);
  }

lumen 5.6 error handler throws exception twice � Issue #742 � laravel , Lumen Version: 5.6.* PHP Version: 7.2.0 Description: This is my code to handle any error: App\Exceptions\Handler::class public function� A Laravel package for captcha recognition for popular services like rucaptcha.com, 2captcha.com, pixodrom.com, captcha24.com, socialink.ru, anti-captcha.com

Configure PHP Lumen 5 HTTP Exception Handlers with common , APP_DEBUG=false (for display json exception responses in production). Authenticate.php use Laravel\Lumen\Exceptions\Handler as ExceptionHandler ;. Become a Laravel Partner. Laravel Partners are elite shops providing top-notch Laravel development and consulting. Each of our partners can help you craft a beautiful, well-architected project.

Lumen is the perfect solution for building Laravel based micro-services and blazing fast APIs. In fact, it's one of the fastest micro-frameworks available. It has never been easier to write stunningly fast services to support your Laravel applications.

Many Laravel services provide functionality to help you easily and expressively write tests, and Laravel's HTTP wrapper is no exception. The Http facade's fake method allows you to instruct the HTTP client to return stubbed / dummy responses when requests are made.

Comments
  • You don't need to use get after find. Find already fetches 1 result from database and get fetches a collection of results.