@@ -61,39 +61,11 @@ Add following code in root blade file in before close the body.
6161```
6262# Repository Generator
6363
64- ## Table of Contents
65- <ol >
66- <li><a href="#features">Features</a></li>
67- <li>
68- <a href="#getting-started">Getting started</a>
69- <ul>
70- <li><a href="#installation">Installation</a></li>
71- <li><a href="#publish-config-(optional)">Publish config (optional)</a></li>
72- </ul>
73- </li>
74- <li>
75- <a href="#usage">Usage</a>
76- <ul>
77- <li><a href="#generating-repositories">Generating repositories</a></li>
78- <li><a href="#dependency-injection">Dependency Injection</a></li>
79- </ul>
80- </li>
81- <li><a href="#manual-binding">Manual binding</a></li>
82- <li><a href="#more-generator-packages">More generator packages</a></li>
83- <li><a href="#contributing">Contributing</a></li>
84- <li><a href="#license">License</a></li>
85- </ol >
86-
8764## Features
8865With this package you can generate repositories with the ``` artisan make:repository ``` command.
8966The generator will generate the repository, repository interface and will bind them automatically (can be changed to
9067manual binding) to the Service Container so you can inject the interface into your controllers.
9168
92- ### Publish config (optional)
93- ```
94- php artisan vendor:publish --provider="RajTechnologies\Tools\ToolServiceProvider" --tag="config"
95- ```
96-
9769## Usage
9870For usage take the following steps. Generate the repository and then inject it into a controller or service.
9971
@@ -107,74 +79,6 @@ This example will generate the following files:
10779app\Repositories\Eloquent\UserRepository
10880app\Repositories\UserRepositoryInterface
10981```
110-
111- ### Dependency Injection
112- Next we have to inject the interface into the constructor our controller or service. For this example we will use the UserController.
113- ``` php
114- <?php
115-
116- namespace App\Http\Controllers;
117-
118- use App\Repositories\UserRepositoryInterface;
119-
120- class UserController extends Controller
121- {
122- private $user;
123-
124- public function __construct(UserRepositoryInterface $userRepository)
125- {
126- $this->user = $userRepository;
127- }
128-
129- // your controller functions
130- }
131- ```
132-
133- By default you will be able to use Eloquent methods like ``` all() ``` and ``` find() ``` .
134- You can extend this in your repository. Now you will be able to use your repository
135- in your methods like this.
136- ``` php
137- public function index()
138- {
139- return $this->user->all();
140- }
141- ```
142- ## Manual binding
143- By default the package will automatically bind the repository interfaces for you with the repositories so you can
144- inject the interface into your controllers. If you want to bind manually you can disable
145- this behaviour by setting the ``` auto_bind_interfaces ``` option to ``` false ``` in ``` config\repository-generator.php ``` .
146- If the config is not there make sure to publish it first as described in the Installation chapter.
147-
148- You can add your bindings to your AppServiceProvider or
149- you can a create a new provider with ``` php artisan make:provider RepositoryServiceProvider ```
150- (don't forget to add it in ``` config\app.php ``` ) and add the bindings in the ``` register() ``` method, see the example below.
151-
152- ``` php
153- <?php
154-
155- namespace App\Providers;
156-
157- use App\Repositories\Eloquent\UserRepository;
158- use App\Repositories\UserRepositoryInterface;
159- use Illuminate\Support\ServiceProvider;
160-
161- /**
162- * Class RepositoryServiceProvider
163- * @package App\Providers
164- */
165- class RepositoryServiceProvider extends ServiceProvider
166- {
167- /**
168- * Register services.
169- *
170- * @return void
171- */
172- public function register()
173- {
174- $this->app->bind(UserRepositoryInterface::class, UserRepository::class);
175- }
176- }
177- ```
17882# Pivot Table Generator
17983
18084## Usage
@@ -190,36 +94,6 @@ php artisan migrate
19094
19195# Service Generator
19296
193- ## Table of Contents
194- <ol >
195- <li><a href="#features">Features</a></li>
196- <li><a href="#installation">Installation</a></li>
197- <li>
198- <a href="#usage">Usage</a>
199- <ul>
200- <li><a href="#generate-services">Generate services</a></li>
201- <li><a href="#generate-services-for-models">Generate services for models</a></li>
202- <li><a href="#generate-services-for-controllers">Generate services for controllers</a></li>
203- </ul>
204- </li>
205- <li>
206- <a href="#the-service-pattern">The service pattern</a>
207- <ul>
208- <li><a href="#when-to-use-the-service-pattern">When to use the service pattern</a></li>
209- <li>
210- <a href="#how-to-use-services">How to use services</a>
211- <ul>
212- <li><a href="#static-methods">Static methods</a></li>
213- <li><a href="#depency-injection">Dependency Injection</a></li>
214- </ul>
215- </li>
216- </ul>
217- </li>
218- <li><a href="#more-generator-packages">More generator packages</a></li>
219- <li><a href="#contributing">Contributing</a></li>
220- <li><a href="#license">License</a></li>
221- </ol >
222-
22397## Usage
22498After installation the ``` php artisan make:service {name} ``` will be available in the list
22599of artisan commands.
@@ -359,6 +233,13 @@ class PostController extends Controller
359233 }
360234}
361235```
236+ # Action Generator
237+
238+ ## Usage
239+ Run the following command on the command-line to generate a new action.
240+ ```
241+ php artisan make:action {name}
242+ ```
362243
363244## Contributing
364245
0 commit comments