so, something wrong with route model binding
Have you tried php artisan route:list to check how the resource parameter is being accepted?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to make a call to an API but for some reason i am getting an empty response.
inside my api.php i've got.
Route::group(['middleware' => 'auth:api'], function(){
Route::apiResource('/KPI','PowerBiController')->parameters(['KPI' => 'ID'])->only(['show']);
});
My controller is the following, the resource is just default.
public function show(PowerBi $powerBi) : PowerBiResource
{
return new PowerBiResource($powerBi);
}
And my model is the following:
class PowerBi extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'PowerBiTable';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'ID';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The connection name for the model.
*
* @var string
*/
protected $connection = 'sqlsrv';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [];
}
if i do die dump on my controller i get a definition of the model, but no info back. my test call is /api/KPI/1.
if i do php artisan tinker
and i App\PowerBi::where('Date','<','2019-07-17')->first(); i do get the first response.
Change this line
public function show(PowerBi $ID) : PowerBiResource
{
dd($ID);
Please or to participate in this conversation.