Level 60
$this->id // does this work?
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hi
I want to get sum of coins table with where in User Model.
class User extends Model
{
public function today_charge()
{
$self = self::class;
$sum = DB::table('coins')->where('user_id', $self->id)
->where('div', 'charge')->where('status', 'confirmed')->sum('amount');
return $sum;
}
}
How can I access self->id ?
Please or to participate in this conversation.