README.md 2.41 KB
Newer Older
Dillenn Terumalai's avatar
Dillenn Terumalai committed
1
<p align="center"><img src="https://banners.beyondco.de/Laravel%20Repository%20Artisan.png?theme=light&packageManager=composer+require&packageName=dterumal%2Flaravel-repository-artisan&pattern=architect&style=style_1&description=Some+useful+Artisan+commands+for+repository+pattern+in+Laravel&md=1&showWatermark=1&fontSize=100px&images=folder-open"></p>
Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
2
3
4
5
6
7

## Installation

You can install the package via composer:

```bash
Dillenn Terumalai's avatar
Dillenn Terumalai committed
8
composer require dterumal/laravel-repository-artisan
Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
9
10
11
12
13
14
15
16
17
18
19

```

## Usage

```php
php artisan make:interface --model=Foo FooInterface
```

This will create an interface `FooInterface` in `App/Contracts` directory using the `Foo` Eloquent model.

Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
20
21
22
23
24
25
26
27
28
29
30
31
```php
php artisan make:interface --base FooInterface
```

This will create a base interface `FooInterface` in `App/Contracts` directory which implements the classic CRUD methods. Pleas note that it will use `Illuminate\Database\Eloquent\Model` instead of a specific model.

```php
php artisan make:interface --extend=FooBase FooInterface
```

This will create an interface `FooInterface` which extends the `FooBase` interface.

Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
32
33
34
35
```php
php artisan make:repository --model=Foo --interface=FooInterface FooRepository
```

Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
36
37
38
39
40
41
42
43
44
45
46
47
48
This will create a repository class `FooRepository` implementing the interface `FooInterface` and using `Foo` Eloquent model.

```php
php artisan make:repository --model=Foo --base=FooInterface FooRepository
```

This will create a repository class `FooRepository` implementing the base interface `FooInterface` and using `Foo` Eloquent model.

```php
php artisan make:repository-controller --model=Foo --interface=FooInterface FooController
```

This will create a controller `FooController` which will inject the give interface `FooInterface` and bind the given model `Foo`
Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

**Note:** When using options such as `--model` or `--interface`, please note that if class/interface doesn't exist, the terminal will prompt you with a confirmation to automatically create it.

## Testing

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
64
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Dillenn Terumalai's avatar
// WIP    
Dillenn Terumalai committed
65
66
67
68
69
70
71
72
73
74
75

## Security Vulnerabilities

Please review [our security policy](.gitlab/SECURITY.md) on how to report security vulnerabilities.

## Credits

- [Dillenn Terumalai](https://gitlab.sib.swiss/dterumal)

## License

Dillenn Terumalai's avatar
Dillenn Terumalai committed
76
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.