Nobody use Nova ?
Mar 8, 2019
6
Level 5
Laravel nova custom card problem
I can't get the resourceId in a custom card, at the compute function. Someone would have the trick?
class CountRelationshipsPerUser extends Card
{
/**
* The width of the card (1/3, 1/2, or full).
*
* @var string
*/
public $width = '1/3';
/**
* @return CountRelationshipsPerUser
*/
public function withCount()
{
$current_user = ????; ///// HERE
return $this->withMeta([
'my_count' => MyModel::where('user_id', $current_user)->count(),
]);
}
/**
* Get the component name for the element.
*
* @return string
*/
public function component()
{
return 'count-relationships-per-user';
}
}
Please or to participate in this conversation.