lundi 10 décembre 2018

Laravel - Filter out 'null' values from request

I am attempting to filter my $request to not include any input data where the qty field is null (qty sits on a pivot table)

I have already attempted:

$qty = $request->input('qty'); //define qty

$filtered = $request->filter(function ($qty, $key) {
   return $qty != null;
});

$filtered->all();

but I receive the error Method Illuminate\Http\Request::filter does not exist, which is strange because I have use Illuminate\Http\Request; in the Controller.

Although I have never filtered data before so I don't know if this is even the correct approach.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire