dimanche 4 février 2018

Access a model method by Laravel ajax

I have an ajax call that calls a method from a controller

public function getVisitas(Request $request)
{
    $visitas = Visita::where('usuario','=',$request->id)->get();
    return $visitas;
}

In my model Visita have the following method

public function getDiff()
{
    $fx = $this->fecha; // attribute fecha
    return Carbon::parse($fx)->diffForHumans();
}

From ajax in my view I can access all the attributes of the Visita class, but I do not know how to access the result of the getDiff method



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire