samedi 10 novembre 2018

How to grab only latest update record from data table in Laravel 5.6?

I have following table name as projects like this structure,

id    name    adtype created_at    updated_at
1     gobba     1      2018-02-25    2018-02-25
2     manna     0      2018-04-25    2018-04-25
3     alaya     1      2017-12-28    2017-12-28

I need grab only one result witch related to latest updated record and adtype == 1, I code following controller, for this,

 public function showad()
     {
 $projects = Vehicle::with('uploads')
            ->where('adtype','=',1)
            ->latest('updated_at');
return view('vehicles.slider')->withProjects($projects);

but this working but not filtering latest updated records. how can correct this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire