I have two tables, say \"users\" and \"users_actions\", where \"users_actions\" has an hasMany relation with users:
users
id | name
Let change a bit the @berkayk's code.
Define this relation in Users model,
Users
public function latestAction() { return $this->hasOne('Action')->latest(); }
And
Users::with(['latestAction' => function ($query) { $query->where('id_action', 1); }])->get();