I can’t find the user and sum

  eloquent, laravel, laravel-5, laravel-8

i have a problem, i need to add the debt of a user


 public function cliente($id){

        // $nota = AppNota::find($id);
        //AquĆ­ valida si existe sino redirije al 404
        $datos = [
            'category_name' => 'datatable',
            'page_name' => 'multiple_tables',
        'registro' => Registro::find($id),


        $cliente = AppModelsUser::findOrFail($id);
        return view('cliente', compact('cliente'))->with($datos);


<div class="row">
<div class="col">
  <h4>Debt Sum:</h4>
<div class="col">
 {{ $registro->user_id->sum('deuda') }}


enter image description here

i need to add the field "deuda" of the user, the relationship is in user_id with the users table

the error that I get is: Trying to get property ‘user_id’ of non-object

help pls

Source: Laravel

Leave a Reply