mercredi 12 décembre 2018

Most Recent Updates in Laravel

I have a list of books in my database and each book have chapters. my models are

Books.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Book extends Model
{
    protected $guarded = [];

    public function chapters()
    {
        return $this->hasMany(Chapter::class);
    }
}

Chapter.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Chapter extends Model
{
    protected $guarded = [];

    public function book()
    {
        return $this->belongsTo(Book::class);
    }
}

How can make a page that will show the books in order manner from latest to old? Also, the order is based on the chapter being updated or added in a book. If one of the old books is being updated by adding 1 more chapter, that book will show first on the most recent updated books. Thank you!

I am using Laravel 5.6 and Vue JS



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EhlEM8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire