You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,25 +24,21 @@ This library provides a simple class to help make a `Presenter` for your objects
24
24
25
25
## Installation
26
26
27
-
### Composer
27
+
```bash
28
+
composer require robclancy/presenter:^2.0
29
+
```
30
+
or
28
31
29
32
Add `robclancy/presenter` to the "require" section of your `composer.json` file.
30
-
31
33
```json
32
-
"robclancy/presenter": "2.0.*"
34
+
"robclancy/presenter": "^2.0"
33
35
```
34
36
35
37
Run `composer update` to get the latest version of the package.
36
38
37
-
38
-
### Manually
39
-
40
-
It's recommended that you use Composer, however you can download and install from this repository.
41
-
42
-
43
39
### Laravel
44
40
45
-
This package comes with an optional service provider for Laravel 5.8+ so that you can automate some extra steps. You will need to have installed using the composer method above, then register the service provider with your application.
41
+
This package comes with an optional service provider for Laravel 5.8+ < Laravel 10 so that you can automate some extra steps. You will need to have installed using the composer method above, then register the service provider with your application.
46
42
47
43
Open `app/config/app.php` and find the `providers` key. Add
48
44
```
@@ -55,7 +51,6 @@ to the array at some point after
55
51
56
52
Now presenters will automatically be created if using the <ahref="#laravel-usage">laravel method</a> described below.
57
53
58
-
59
54
## Usage
60
55
61
56
`Presenter` is a very simple class that overloads methods and variables so that you can add extra logic to your objects or arrays without adding view logic to areas like your models or controllers and also keeps any extra logic out of your views.
@@ -76,7 +71,7 @@ class UserPresenter extends Robbo\Presenter\Presenter {
76
71
```
77
72
78
73
Now our view should receive an instance of this presenter which would be created with something like `$user = new UserPresenter(new User);`. If we want to link to the users page all we have to do is call `$user->url()`. Now you have good separation of logic and an easy little class you can modify to add properties to your `User` in all areas.
79
-
However you might not want to be calling methods like this, it could be inconsistent with what you are doing or you might want the code to look a little cleaner. That is where methods with the `present` prefix come in. All we do is update the presenter to the following.
74
+
However, you might not want to be calling methods like this, it could be inconsistent with what you are doing, or you might want the code to look a little cleaner. That is where methods with the `present` prefix come in. All we do is update the presenter to the following.
80
75
81
76
```php
82
77
@@ -266,6 +261,12 @@ And that is all there is to it. You can easily automate the creation of presente
0 commit comments