PHP code example of lorisleiva / laravel-add-select
1. Go to this page and download the library: Download lorisleiva/laravel-add-select library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lorisleiva / laravel-add-select example snippets
class Book extends Model
{
use AddSubSelects;
public function addLastChapterIdSelect()
{
return Chapter::select('id')
->whereColumn('book_id', 'books.id')
->latest();
}
public function addLatestVersionSelect()
{
return Chapter::select('version')
->whereColumn('book_id', 'books.id')
->orderByDesc('version');
}
}