1. Go to this page and download the library: Download a2design/eloquent-presenter 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/ */
a2design / eloquent-presenter example snippets
use BrianFaust\Presenter\HasViewPresenterTrait;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
use HasViewPresenterTrait;
/**
* Get the view presenter for the model.
*
* @return string
*/
protected function getPresenter()
{
return UserPresenter::class;
}
}
php
use BrianFaust\Presenter\BasePresenter;
class CommentPresenter extends BasePresenter
{
public function getRoutePrefix()
{
return 'users.posts.comments';
}
public function getRouteParameters()
{
// The ID of the model will be automatically attached to this array at the end
// [
// $model->post->user->id,
// $model->post->id,
// $model->id // "id" is what is specified in $this->getRouteKeyName()
// ];
return ['post.user.id', 'post.id'];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.