1. Go to this page and download the library: Download emadha/eloquent-views 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/ */
emadha / eloquent-views example snippets
return [
/**
* The root directory of Eloquent views path in resources
* by default it's using /resources/eloquent/{model name}
*/
'path' => 'eloquent',
];
...
class Post extends Model {
use \EmadHa\EloquentViews\HasEloquentViews;
...
}
# Render a single model view
Post::first()->render('block'); // Single block, rendered.
# Build views for a colletion of models
# This will return a collection object.
Post::all()->render('block');
# You can use 'implode' to get this as a single html string e.g. ...->implode(null);
Post::all()->render('block')->implode(null);