Creating New Model Presenter

This package gives you an easy way to generate new Presenter class, all you need to do is to use presenter:make command.

1php artisan presenter:make UserPresneter

UserPresenter in our case, leaves by default in App\Presenters.

This is the contents of the UserPresenter file:

1<?php
2 
3namespace App\Presenters;
4 
5use Coderflex\LaravelPresenter\Presenter;
6 
7class UserPresenter extends Presenter
8{
9 //
10}

If you want to change the directory, you have two options.

First options is to set the full namespace while you're creating the presenter class

1php artisna presneter:make App\Models\Presenter\UserPresenter

Or change presenter_namespace from config/laravel-presenter file.

1return [
2 ...
3 
4 'presenter_namespace' => 'App\\Presenters',
5 
6 ...
7];

Join our newsletter

Subscribe to Our Newsletter and never miss our offers, latest news, Articles, etc.

We care about the protection of your data. Read our Privacy Policy.