master 124fa0d81691 cached
55 files
78.2 KB
19.9k tokens
157 symbols
1 requests
Download .txt
Repository: tiagomichaelsousa/LaravelResources
Branch: master
Commit: 124fa0d81691
Files: 55
Total size: 78.2 KB

Directory structure:
gitextract_vkyfqi4p/

├── .all-contributorsrc
├── .github/
│   └── workflows/
│       ├── composer-normalize.yml
│       └── run-tests.yml
├── .gitignore
├── .styleci.yml
├── README.md
├── changelog.md
├── code_of_conduct.md
├── composer.json
├── config/
│   └── laravel-resources.php
├── contributing.md
├── license.md
├── phpunit.xml
├── src/
│   ├── Commands/
│   │   └── ResourceCommand.php
│   ├── Exceptions/
│   │   └── File.php
│   ├── Generators/
│   │   ├── AbstractGenerator.php
│   │   ├── CollectionGenerator.php
│   │   ├── ControllerGenerator.php
│   │   ├── FactoryGenerator.php
│   │   ├── Generator.php
│   │   ├── MigrationGenerator.php
│   │   ├── ModelGenerator.php
│   │   ├── PolicyGenerator.php
│   │   ├── RequestGenerator.php
│   │   ├── ResourceGenerator.php
│   │   ├── RouteGenerator.php
│   │   └── SeederGenerator.php
│   ├── Helpers/
│   │   └── helpers.php
│   ├── LaravelResourcesServiceProvider.php
│   └── stubs/
│       ├── controllers/
│       │   ├── controller.method.destroy.stub
│       │   ├── controller.method.index.stub
│       │   ├── controller.method.show.stub
│       │   ├── controller.method.store.stub
│       │   ├── controller.method.update.stub
│       │   └── controller.stub
│       ├── factories/
│       │   └── factory.stub
│       ├── migrations/
│       │   └── migration.stub
│       ├── models/
│       │   └── model.stub
│       ├── policies/
│       │   └── api.policies.stub
│       ├── requests/
│       │   └── api.request.stub
│       ├── resources/
│       │   ├── api.collection.stub
│       │   └── api.resource.stub
│       ├── routes/
│       │   └── api.routes.stub
│       └── seeds/
│           └── seed.stub
└── tests/
    ├── CollectionGeneratorTest.php
    ├── ControllerGeneratorTest.php
    ├── FactoryGeneratorTest.php
    ├── MigrationGeneratorTest.php
    ├── ModelGeneratorTest.php
    ├── PolicyGeneratorTest.php
    ├── RequestGeneratorTest.php
    ├── ResourceCommandTest.php
    ├── ResourceGeneratorTest.php
    ├── SeederGeneratorTest.php
    └── TestCase.php

================================================
FILE CONTENTS
================================================

================================================
FILE: .all-contributorsrc
================================================
{
  "files": [
    "README.md"
  ],
  "imageSize": 100,
  "commit": false,
  "contributors": [
    {
      "login": "RafaelFerreiraTVD",
      "name": "Rafael Ferreira",
      "avatar_url": "https://avatars1.githubusercontent.com/u/15105462?v=4",
      "profile": "http://www.xgeeks.io",
      "contributions": [
        "doc"
      ]
    },
    {
      "login": "tiagomichaelsousa",
      "name": "tiagomichaelsousa",
      "avatar_url": "https://avatars1.githubusercontent.com/u/28356381?v=4",
      "profile": "https://github.com/tiagomichaelsousa",
      "contributions": [
        "code",
        "doc",
        "content",
        "review"
      ]
    },
    {
      "login": "white-hyena",
      "name": "White Hyena",
      "avatar_url": "https://avatars3.githubusercontent.com/u/62600397?v=4",
      "profile": "https://github.com/white-hyena",
      "contributions": [
        "code",
        "content"
      ]
    },
    {
      "login": "pkboom",
      "name": "Keunbae Park",
      "avatar_url": "https://avatars2.githubusercontent.com/u/13960169?v=4",
      "profile": "https://github.com/pkboom",
      "contributions": [
        "code",
        "content"
      ]
    }
  ],
  "contributorsPerLine": 7,
  "projectName": "LaravelResources",
  "projectOwner": "tiagomichaelsousa",
  "repoType": "github",
  "repoHost": "https://github.com",
  "skipCi": true
}


================================================
FILE: .github/workflows/composer-normalize.yml
================================================
name: Composer Normalize

on:
    push:
        paths:
            - "composer.json"

jobs:
    normalize:
        runs-on: ubuntu-latest
        steps:
            - name: Git checkout
              uses: actions/checkout@v3

            - name: normalize composer.json
              run: |
                  composer global require ergebnis/composer-normalize
                  composer normalize
            - uses: stefanzweifel/git-auto-commit-action@v4
              with:
                  commit_message: Normalize composer.json


================================================
FILE: .github/workflows/run-tests.yml
================================================
name: CI

on: ['push', 'pull_request']

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        php:
          - '8.0'
          - '8.1'
          - '8.2'
        laravel:
          - 8.*
          - 9.*
          - 10.*
        prefer:
          - 'prefer-stable'
        include:
          - laravel: 8.*
            testbench: 6.*
          - laravel: 9.*
            testbench: 7.*
          - laravel: 10.*
            testbench: 8.*
        exclude:
          - laravel: 10.*
            php: 8.0

    name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} --${{ matrix.prefer }}

    steps:
      - uses: actions/checkout@v2.4.0

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, yaml
          coverage: pcov

      - uses: actions/cache@v2.1.7
        name: Cache dependencies
        with:
          path: ~/.composer/cache/files
          key: composer-php-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.prefer }}-${{ hashFiles('composer.json') }}

      - name: Install dependencies
        run: |
          composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
          composer update --${{ matrix.prefer }} --prefer-dist --no-interaction --no-suggest

      - name: Run tests
        run: |
          vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml


================================================
FILE: .gitignore
================================================
/.phpunit.result.cache
/build/
/vendor/
/tests/temp
composer.lock
composer.phar
.idea
/report
.DS_Store
coverage.clover


================================================
FILE: .styleci.yml
================================================
preset: laravel

finder:
    name:
        - "*.php"


================================================
FILE: README.md
================================================
# Laravel Resources

<p align="center">
    <img src="./docs/demo.gif" alt="Laravel Resources Demo" width="480">
</p>

<p align="center">
    <img src="https://img.shields.io/packagist/v/tiagomichaelsousa/laravelresources.svg?style=flat-square" alt="Packagist Version">
    <img src="https://img.shields.io/packagist/dt/tiagomichaelsousa/laravelresources.svg?style=flat-square" alt="Packagist Downloads">
    <img src="https://img.shields.io/travis/tiagomichaelsousa/laravelresources/master.svg?style=flat-square" alt="Build Status">
    <img src="https://github.styleci.io/repos/236964942/shield" alt="Style Status">
    <img src="https://poser.pugx.org/tiagomichaelsousa/laravelresources/license?format=flat-square" alt="Licence">
    <img src="https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square" alt="All Contributors">
    <img src="https://api.codacy.com/project/badge/Grade/8c5fafbbbf524b4db771a7bb1c55bb39" alt="Code Quality">
    <img src="https://api.codacy.com/project/badge/Coverage/8c5fafbbbf524b4db771a7bb1c55bb39" alt="Code Coverage">

</p>

---

Laravel Resources is a speed-up development package that allows you to create a boilerplate for Laravel apps with a default API structure.

## Versions

| Laravel  | Laravel Resources |
|----------| ----------------- |
| 7.x      | v1.7              |
| 8.x      | v2.x              |
| 9.x      | v2.x              |
| 10.x     | v3.x              |

## Installation

Via Composer

```bash
$ composer require tiagomichaelsousa/laravelresources --dev
```

## Usage

Create the resources

```bash
$ php artisan resources:create <model>
```

This command will create the Controller, the Request, the Policy, the API Resource and Collection and will also add the default routes for the API.

Publish configuration file

```bash
$ php artisan vendor:publish --provider="tiagomichaelsousa\LaravelResources\LaravelResourcesServiceProvider" --tag="config"
```

**Notes:**

-   This package is fully configurable. You can change all the namespaces for the resources that will be created in the config file.
-   Don't forget to edit the request file in order to add your default validation for the model.
-   Don't forget to edit the policy file in order to fulfill your app business logic.

## Change log

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

## Testing

```bash
$ composer test
```

### With test coverage

```bash
$ composer test-report
```

## Contributing

Please see [contributing.md](contributing.md) for details and a todolist.

## Security

If you discover any security related issues, please email the [author](mailto:tiagomichaelsousa@gmail.com) instead of using the issue tracker.

## Credits

-   [@tiagomichaelsousa][link-author]
-   [All Contributors][link-contributors]

## License

License MIT. Please see the [license file](license.md) for more information.

## Code Of Conduct

Please see the [code of conduct](code_of_conduct.md) for more information.

[ico-version]: https://img.shields.io/packagist/v/tiagomichaelsousa/laravelresources.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/tiagomichaelsousa/laravelresources.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/tiagomichaelsousa/laravelresources/master.svg?style=flat-square
[ico-styleci]: https://github.styleci.io/repos/236964942/shield
[link-packagist]: https://packagist.org/packages/tiagomichaelsousa/laravelresources
[link-downloads]: https://packagist.org/packages/tiagomichaelsousa/laravelresources
[link-travis]: https://travis-ci.org/tiagomichaelsousa/laravelresources
[link-styleci]: https://styleci.io/repos/236964942
[link-author]: https://github.com/tiagomichaelsousa
[link-contributors]: ../../contributors

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="http://www.xgeeks.io"><img src="https://avatars1.githubusercontent.com/u/15105462?v=4" width="100px;" alt=""/><br /><sub><b>Rafael Ferreira</b></sub></a><br /><a href="https://github.com/tiagomichaelsousa/LaravelResources/commits?author=RafaelFerreiraTVD" title="Documentation">📖</a></td>
    <td align="center"><a href="https://github.com/tiagomichaelsousa"><img src="https://avatars1.githubusercontent.com/u/28356381?v=4" width="100px;" alt=""/><br /><sub><b>tiagomichaelsousa</b></sub></a><br /><a href="https://github.com/tiagomichaelsousa/LaravelResources/commits?author=tiagomichaelsousa" title="Code">💻</a> <a href="https://github.com/tiagomichaelsousa/LaravelResources/commits?author=tiagomichaelsousa" title="Documentation">📖</a> <a href="#content-tiagomichaelsousa" title="Content">🖋</a> <a href="https://github.com/tiagomichaelsousa/LaravelResources/pulls?q=is%3Apr+reviewed-by%3Atiagomichaelsousa" title="Reviewed Pull Requests">👀</a></td>
    <td align="center"><a href="https://github.com/white-hyena"><img src="https://avatars3.githubusercontent.com/u/62600397?v=4" width="100px;" alt=""/><br /><sub><b>White Hyena</b></sub></a><br /><a href="https://github.com/tiagomichaelsousa/LaravelResources/commits?author=white-hyena" title="Code">💻</a> <a href="#content-white-hyena" title="Content">🖋</a></td>
    <td align="center"><a href="https://github.com/pkboom"><img src="https://avatars2.githubusercontent.com/u/13960169?v=4" width="100px;" alt=""/><br /><sub><b>Keunbae Park</b></sub></a><br /><a href="https://github.com/tiagomichaelsousa/LaravelResources/commits?author=pkboom" title="Code">💻</a> <a href="#content-pkboom" title="Content">🖋</a></td>
  </tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!


================================================
FILE: changelog.md
================================================
# Changelog

All notable changes to `LaravelResources` will be documented in this file.

## Version 1.0

### Added
- Everything


================================================
FILE: code_of_conduct.md
================================================
# Code Of Conductd

This code of conduct is derived from the Ruby code of conduct. Any violations of the code of conduct may be reported to [author](tiagomichaelsousa@gmail.com).

- Participants will be tolerant of opposing views.
- Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
- When interpreting the words and actions of others, participants should always assume good intentions.
- Behavior which can be reasonably considered harassment will not be tolerated.


================================================
FILE: composer.json
================================================
{
  "name": "tiagomichaelsousa/laravelresources",
  "description": "Laravel Resources is a speed-up development package that allows you to create a boilerplate for Laravel apps with a default API structure.",
  "license": "MIT",
  "authors": [
    {
      "name": "tiagomichaelsousa",
      "email": "tiagomichaelsousa@gmail.com",
      "homepage": "https://github.com/tiagomichaelsousa",
      "role": "Developer"
    }
  ],
  "homepage": "https://github.com/tiagomichaelsousa/laravelresources",
  "keywords": [
    "Laravel",
    "LaravelResources",
    "laravelresources",
    "laravel-resources"
  ],
  "require": {
    "illuminate/support": "^7.0|^8.0|^9.0|^10.0"
  },
  "require-dev": {
    "phpunit/phpunit": "^8.5|^9.0|^10.0",
    "mockery/mockery": "^1.3.1",
    "sempro/phpunit-pretty-print": "^1.4",
    "orchestra/testbench": "^8.5"
  },
  "autoload": {
    "files": [
      "src/Helpers/helpers.php"
    ],
    "psr-4": {
      "tiagomichaelsousa\\LaravelResources\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "tiagomichaelsousa\\LaravelResources\\Tests\\": "tests"
    }
  },
  "scripts": {
    "test": "vendor/bin/phpunit",
    "test-report": "vendor/bin/phpunit --coverage-html report"
  },
  "extra": {
    "laravel": {
      "providers": [
        "tiagomichaelsousa\\LaravelResources\\LaravelResourcesServiceProvider"
      ],
      "aliases": {
        "LaravelResources": "tiagomichaelsousa\\LaravelResources\\Facades\\LaravelResources"
      }
    }
  }
}


================================================
FILE: config/laravel-resources.php
================================================
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Controller configs
    |--------------------------------------------------------------------------
    |
    | This values are used when a new controller is created.
    | If you change the namespace, it will automatically create the controller in the folder base path.
    | The suffix and prefix are variables that can be edited to change the class name for the controller
    |
    */
    'controllers' => [
        'namespace' => 'App\Http\Controllers',
        'suffix' => 'API',
        'prefix' => null,
    ],

    /*
    |--------------------------------------------------------------------------
    | Resources configs
    |--------------------------------------------------------------------------
    |
    | This values are used when a new resource is created.
    | If you change the namespace, it will automatically create the resource in the folder base path.
    | The suffix and prefix are variables that can be edited to change the class name for the controller.
    | When you create a resource you can also create a collection that will inherit the data from the resource.
    | The collection class will also have the possibility to define the suffix and prefix for the class name.
    |
    */
    'resources' => [
        'namespace' => 'App\Http\Resources',
        'suffix' => null,
        'prefix' => null,
    ],

    'collections' => [
        'namespace' => 'App\Http\Resources\Collections',
        'suffix' => null,
        'prefix' => null,
    ],

    /*
    |--------------------------------------------------------------------------
    | Resources configs
    |--------------------------------------------------------------------------
    |
    | This values are used when a new resource is created.
    | If you change the namespace, it will automatically create the resource in the folder base path.
    | The suffix and prefix are variables that can be edited to change the class name for the controller.
    | When you create a resource you can also create a collection that will inherit the data from the resource.
    | The collection class will also have the possibility to define the suffix and prefix for the class name.
    |
    */
    'requests' => [
        'namespace' => 'App\Http\Requests',
        'suffix' => null,
        'prefix' => null,
    ],

    /*
    |--------------------------------------------------------------------------
    | Policies configs
    |--------------------------------------------------------------------------
    |
    | This values are used when a new policy is created.
    | If you change the namespace, it will automatically create the resource in the folder base path.
    | The suffix and prefix are variables that can be edited to change the class name for the policy.
    |
    */
    'policies' => [
        'namespace' => 'App\Policies',
        'suffix' => null,
        'prefix' => null,
    ],

    /*
    |--------------------------------------------------------------------------
    | Model configs
    |--------------------------------------------------------------------------
    |
    | This config is used to fetch the models from the namespace.
    | Many projects change the path for the models to /app/models and thats the mainly reason
    | for the usage of this config value.
    |
    */
    'models' => [
        'namespace' => 'App\Models',
    ],

    /*
    |--------------------------------------------------------------------------
    | Routes configs
    |--------------------------------------------------------------------------
    |
    | This config is used set the path and the filename where the stubs for the routes
    | will be added.
    |
    */
    'routes' => [
        'path' => 'routes',
        'filename' => 'api.php',
    ],

    /*
    |--------------------------------------------------------------------------
    | Database configs
    |--------------------------------------------------------------------------
    |
    | This config is used to set the path for the migrations, factories and seeds
    | This configs should not be edited if you dont change the laravel mapping folders
    |
    */
    'database' => [
        'migrations' => 'database/migrations',
        'factories' => 'database/factories',
        'seeds' => 'database/seeders',
    ],
];


================================================
FILE: contributing.md
================================================
# Contributing

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on [Github](https://github.com/tiagomichaelsousa/laravelresources).

# Things you could do

If you want to contribute but do not know where to start, this list provides some starting points.

- Set up TravisCI, StyleCI
- Write a comprehensive ReadMe

## Pull Requests

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!


================================================
FILE: license.md
================================================
# The license

Copyright 2020 [@tiagomichaelsousa](https://github.com/tiagomichaelsousa)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: phpunit.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
  <coverage>
    <include>
      <directory>src/</directory>
    </include>
  </coverage>
  <testsuites>
    <testsuite name="Laravel Resources Test Suite">
      <directory>tests/</directory>
    </testsuite>
  </testsuites>
</phpunit>


================================================
FILE: src/Commands/ResourceCommand.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use tiagomichaelsousa\LaravelResources\Generators\CollectionGenerator;
use tiagomichaelsousa\LaravelResources\Generators\ControllerGenerator;
use tiagomichaelsousa\LaravelResources\Generators\FactoryGenerator;
use tiagomichaelsousa\LaravelResources\Generators\MigrationGenerator;
use tiagomichaelsousa\LaravelResources\Generators\ModelGenerator;
use tiagomichaelsousa\LaravelResources\Generators\PolicyGenerator;
use tiagomichaelsousa\LaravelResources\Generators\RequestGenerator;
use tiagomichaelsousa\LaravelResources\Generators\ResourceGenerator;
use tiagomichaelsousa\LaravelResources\Generators\RouteGenerator;
use tiagomichaelsousa\LaravelResources\Generators\SeederGenerator;

class ResourceCommand extends Command
{
    /**
     * The resources that can be created.
     *
     * @var array
     */
    private $resources = [
        ResourceGenerator::class,
        CollectionGenerator::class,
        RequestGenerator::class,
        PolicyGenerator::class,
        ControllerGenerator::class,
        RouteGenerator::class,
    ];

    /**
     * The resources that can be created if the model does not exists.
     *
     * @var array
     */
    private $modelResources = [
        'migration' => MigrationGenerator::class,
        'factory' => FactoryGenerator::class,
        'seeder' => SeederGenerator::class,
    ];

    /**
     * The model name for the resources.
     *
     * @var string
     */
    private $model;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'resources:create
                            {model : The model for the resource}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'This command will allow you to create all resources that you need for a clean api code structure';

    /**
     * Verify if the model exists to create the resources.
     *
     * @return bool
     */
    private function modelExists()
    {
        return File::exists(base_path(lcfirst(str_replace('\\', '/', config('laravel-resources.models.namespace'))))."/{$this->model}.php");
    }

    /**
     * Create the model if does not exists.
     *
     * @return void
     */
    private function createModelResources()
    {
        foreach ($this->modelResources as $resource => $generator) {
            if ($this->confirm("Should I create the {$resource} for {$this->model}?", true)) {
                array_push($this->resources, $generator);
            }
        }
    }

    /**
     * Create the resources for the model.
     *
     * @return void
     */
    private function createResources()
    {
        $this->info('Creating '.count($this->resources).' resources ...');
        $this->line('');

        $bar = $this->getOutput()->createProgressBar(count($this->resources));

        foreach ($this->resources as $resource) {
            (new $resource($this->model))->handle();
            $bar->advance();
        }

        $bar->finish();
        $this->line('');

        $this->line('');

        $this->info('🚀 Resources created successfully 🚀');
        $this->line('');

        exec('composer dumpautoload');
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info('Checking if the model exists ...');

        $this->model = $this->argument('model');

        if (! $this->modelExists()) {
            $this->info("The model {$this->model} does not exists.");

            if (! $this->confirm('Should I create it?', true)) {
                return;
            }

            (new ModelGenerator($this->model))->handle();

            $this->createModelResources();
        }

        $this->createResources();
    }
}


================================================
FILE: src/Exceptions/File.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Exceptions;

use Exception;

class File extends Exception
{
    public static function alreadyExistsInDirectory(string $path)
    {
        return new static("The file already exists in the path $path");
    }

    public static function doesNotExists(string $path)
    {
        return new static("The file doesn't exists in the path $path");
    }
}


================================================
FILE: src/Generators/AbstractGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;
use tiagomichaelsousa\LaravelResources\Exceptions\File as FileException;

abstract class AbstractGenerator implements Generator
{
    /**
     * The model for that will be used in the policy.
     *
     * @var string
     */
    protected $model;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct($model)
    {
        $this->model = $model;
    }

    /**
     * Verify if the directory and create one if it doesn't.
     *
     * @return bool
     */
    public function directoryExists($path)
    {
        return (bool) File::isDirectory($path) ?: make_directory($path);
    }

    /**
     * Verify if the resource already exists.
     *
     * @return mixed|\tiagomichaelsousa\LaravelResources\Exceptions\File
     */
    public function fileAlreadyExists($path)
    {
        if (File::exists($path)) {
            throw FileException::alreadyExistsInDirectory($path);
        }
    }

    /**
     * Generate the file name.
     *
     * @return string
     */
    public function fileName()
    {
        return "{$this->className()}.php";
    }
}


================================================
FILE: src/Generators/CollectionGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class CollectionGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the collection.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/resources/api.collection.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{NAMESPACE}}' => config('laravel-resources.collections.namespace'),
            '{{CLASS_NAME}}' => "{$this->className()}",
            '{{RESOURCE_NAMESPACE}}' => config('laravel-resources.resources.namespace'),
            '{{RESOURCE_CLASS_NAME}}' =>  create_class_name($this->model, ResourceGenerator::class),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return create_class_name($this->model, self::class);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.collections.namespace');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/ControllerGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\File;

class ControllerGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the controller.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/controllers/controller.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge(
            [
                '{{NAMESPACE}}' => config('laravel-resources.controllers.namespace'),
                '{{CONTROLLER_NAMESPACE}}' => config('laravel-resources.controllers.namespace'),
                '{{CONTROLLER_NAME}}' => "{$this->className()}",
                '{{RESOURCE_NAMESPACE}}' => config('laravel-resources.resources.namespace').'\\'.create_class_name($this->model, ResourceGenerator::class),
                '{{RESOURCE_COLLECTION_NAMESPACE}}' => config('laravel-resources.collections.namespace').'\\'.create_class_name($this->model, CollectionGenerator::class),
                '{{MODEL_CLASS}}' => "{$this->model}",
            ],
            $this->modelReplacements(),
            $this->requestReplacements(),
            $this->methodsReplacements()
        );
    }

    /**
     * Get the replacements for the stub methods.
     *
     * @return array
     */
    private function methodsReplacements()
    {
        $methods = [];

        foreach (['index', 'store', 'show', 'update', 'destroy'] as $method) {
            $stub = File::get(__DIR__."/../stubs/controllers/controller.method.{$method}.stub");

            $replaces = [
                '{{CLASS_NAME}}' => $this->model,
                '{{RESOURCE_NAME}}' => $method === 'index' ? create_class_name($this->model, CollectionGenerator::class) : create_class_name($this->model, ResourceGenerator::class),
                '{{CLASS_VARIABLE}}' => lcfirst($this->model),
            ];

            $methodStubName = strtoupper($method);

            array_push($methods, ["{{{$methodStubName}_METHOD}}" => str_replace(array_keys($replaces), array_values($replaces), $stub)]);
        }

        return Arr::collapse($methods);
    }

    /**
     * Get the replacements for the current model.
     *
     * @return array
     */
    public function modelReplacements()
    {
        return [
            '{{MODEL_CLASS}}' => $this->model,
            '{{MODEL_VARIABLE}}' => lcfirst($this->model),
            '{{MODEL_NAMESPACE}}' => config('laravel-resources.models.namespace')."\\{$this->model}",
        ];
    }

    /**
     * Get the replacements for the current request of the current model.
     *
     * @return array
     */
    public function requestReplacements()
    {
        $requestClass = create_class_name($this->model, RequestGenerator::class);

        return [
            '{{REQUEST_CLASS}}' =>  $requestClass,
            '{{REQUEST_NAMESPACE}}' => config('laravel-resources.requests.namespace')."\\{$requestClass}",
        ];
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return create_class_name($this->model, self::class);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.controllers.namespace');
        $directory = namespace_path($namespace);

        $path = "{$directory}/{$this->filename()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);

        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/FactoryGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class FactoryGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the policy.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/factories/factory.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{MODEL_NAMESPACE}}' => config('laravel-resources.models.namespace'),
            '{{MODEL_NAME}}' => $this->model,
            '{{CLASS_NAME}}' => $this->className(),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return "{$this->model}Factory";
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.database.factories');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/Generator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

interface Generator
{
    public function getStub();

    public function replacements();

    public function fileAlreadyExists($path);

    public function directoryExists($path);

    public function className();

    public function fileName();

    public function handle();
}


================================================
FILE: src/Generators/MigrationGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Carbon\Carbon;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

class MigrationGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the policy.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/migrations/migration.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{CLASS_NAME}}' => $this->className(),
            '{{TABLE_NAME}}' => Str::lower(Str::snake(Str::plural($this->model))),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        $name = Str::plural($this->model);

        return "Create{$name}Table";
    }

    /**
     * Generate the file name.
     *
     * @return string
     */
    public function fileName()
    {
        $date = Carbon::now()->format('Y_m_d_Hms');
        $name = Str::lower(Str::snake($this->className()));

        return "{$date}_{$name}.php";
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.database.migrations');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/ModelGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class ModelGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the policy.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/models/model.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{NAMESPACE}}' => config('laravel-resources.models.namespace'),
            '{{CLASS_NAME}}' => $this->model,
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return ucfirst($this->model);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.models.namespace');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/PolicyGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class PolicyGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the policy.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/policies/api.policies.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{NAMESPACE}}' => config('laravel-resources.policies.namespace'),
            '{{CLASS_NAME}}' => "{$this->className()}",
            '{{MODEL_NAMESPACE}}' => config('laravel-resources.models.namespace'),
            '{{MODEL_NAME}}' => config('laravel-resources.models.namespace'),
            '{{MODEL_CLASS}}' => $this->model,
            '{{MODEL_VARIABLE}}' => lcfirst($this->model),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return create_class_name($this->model, self::class);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.policies.namespace');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/RequestGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class RequestGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the request.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/requests/api.request.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{NAMESPACE}}' => config('laravel-resources.requests.namespace'),
            '{{CLASS_NAME}}' => $this->className(),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return create_class_name($this->model, self::class);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.requests.namespace');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->filename()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/ResourceGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;

class ResourceGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the request.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/resources/api.resource.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{NAMESPACE}}' => config('laravel-resources.resources.namespace'),
            '{{CLASS_NAME}}' => "{$this->className()}",
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return create_class_name($this->model, self::class);
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.resources.namespace');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->filename()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Generators/RouteGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use tiagomichaelsousa\LaravelResources\Exceptions\File as FileException;

class RouteGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the request.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/routes/api.routes.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{MODEL_NAME}}' => $this->model,
            '{{MODEL_VARIABLE}}' => lcfirst($this->model),
            '{{CONTROLLER_NAME}}' => $this->generateControllerName(),
            '{{ROUTE_NAME}}' => Str::plural(Str::kebab($this->model)),
        ]);
    }

    /**
     * Verify if the resource already exists.
     *
     * @return mixed|\tiagomichaelsousa\LaravelResources\Exceptions\File
     */
    public function fileAlreadyExists($path)
    {
        if (File::missing($path)) {
            throw FileException::doesNotExists($path);
        }
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        return 'Route';
    }

    /**
     * Generate the file name.
     *
     * @return string
     */
    public function fileName()
    {
        return config('laravel-resources.routes.filename');
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $path = config('laravel-resources.routes.path');
        $directory = base_path($path);
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        $controllerNamespace = config('laravel-resources.controllers.namespace');
        $controllerImport = "use {$controllerNamespace}\\{$this->generateControllerName()}";
        $content = str_replace("<?php\n", "<?php\n\n$controllerImport;", file_get_contents($path));
        file_put_contents($path, $content);

        file_put_contents($path, [$stub, PHP_EOL], FILE_APPEND | FILE_USE_INCLUDE_PATH);
    }

    /**
     * Generates the controller name.
     *
     * @return string
     */
    private function generateControllerName()
    {
        return create_class_name($this->model, 'ControllerGenerator');
    }
}


================================================
FILE: src/Generators/SeederGenerator.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Generators;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

class SeederGenerator extends AbstractGenerator
{
    /**
     * Get the Stub for the policy.
     *
     * @return string
     */
    public function getStub()
    {
        return File::get(__DIR__.'/../stubs/seeds/seed.stub');
    }

    /**
     * Get the replacements for the stub.
     *
     * @return array
     */
    public function replacements()
    {
        return array_merge([
            '{{MODEL_NAMESPACE}}' => config('laravel-resources.models.namespace'),
            '{{MODEL_NAME}}' => $this->model,
            '{{MODEL_PLURAL}}' => Str::plural($this->model),
            '{{CLASS_NAME}}' => $this->className(),
        ]);
    }

    /**
     * Generate the class name.
     *
     * @return string
     */
    public function className()
    {
        $plural = Str::plural($this->model);

        return "{$plural}TableSeeder";
    }

    /**
     * Handle the resource creation.
     *
     * @return void
     */
    public function handle()
    {
        $namespace = config('laravel-resources.database.seeds');
        $directory = base_path(lcfirst(str_replace('\\', '/', $namespace)));
        $path = "{$directory}/{$this->fileName()}";

        $this->fileAlreadyExists($path);

        $replaces = $this->replacements($this->model);
        $stub = str_replace(array_keys($replaces), array_values($replaces), $this->getStub());

        $this->directoryExists($directory);

        file_put_contents($path, $stub);
    }
}


================================================
FILE: src/Helpers/helpers.php
================================================
<?php

use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

if (! function_exists('make_directory')) {
    /**
     * Create recursive directory.
     *
     * @param  string  $path
     * @param  string  $mode
     * @param  bool  $recursive
     * @param  bool  $force
     * @return bool
     */
    function make_directory($path, int $mode = 0755, bool $recursive = true, bool $force = false)
    {
        return File::makeDirectory($path, $mode, $recursive, $force);
    }
}

if (! function_exists('namespace_path')) {
    /**
     * Receive a namespace and convert it to a path.
     *
     * @param  string  $path
     * @return string
     */
    function namespace_path($path)
    {
        return base_path(lcfirst(str_replace('\\', '/', $path)));
    }
}

if (! function_exists('create_class_name')) {
    /**
     * Receive a classname for a resource.
     *
     * @param  string  $path
     * @return string
     */
    function create_class_name($model, $resource)
    {
        $resource = Str::before(class_basename($resource), 'Generator');
        $configKey = Str::plural(strtolower($resource));
        $className = "{$model}{$resource}";

        if (! is_null($suffix = config("laravel-resources.{$configKey}.suffix"))) {
            $className = Str::finish($className, $suffix);
        }

        if (! is_null($prefix = config("laravel-resources.{$configKey}.prefix"))) {
            $className = Str::start($className, $prefix);
        }

        return $className;
    }
}


================================================
FILE: src/LaravelResourcesServiceProvider.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources;

use Illuminate\Support\ServiceProvider;

class LaravelResourcesServiceProvider extends ServiceProvider
{
    /**
     * The console commands.
     *
     * @var array
     */
    protected $commands = [
        'tiagomichaelsousa\LaravelResources\Commands\ResourceCommand',
    ];

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        // Publishing is only necessary when using the CLI.
        if ($this->app->runningInConsole()) {
            $this->bootForConsole();
        }
    }

    /**
     * Register any package services.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/laravel-resources.php', 'laravel-resources');
    }

    /**
     * Console-specific booting.
     *
     * @return void
     */
    protected function bootForConsole()
    {
        // Publishing the configuration file.
        $this->publishes([
            __DIR__.'/../config/laravel-resources.php' => app()->basePath().'/config/laravel-resources.php',
        ], 'config');

        // Registering package commands.
        $this->commands($this->commands);
    }
}


================================================
FILE: src/stubs/controllers/controller.method.destroy.stub
================================================
${{CLASS_VARIABLE}}->delete();

        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});


================================================
FILE: src/stubs/controllers/controller.method.index.stub
================================================
${{CLASS_VARIABLE}} = {{CLASS_NAME}}::all();

        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});


================================================
FILE: src/stubs/controllers/controller.method.show.stub
================================================
return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});


================================================
FILE: src/stubs/controllers/controller.method.store.stub
================================================
${{CLASS_VARIABLE}} = {{CLASS_NAME}}::create($request->validated());

        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});


================================================
FILE: src/stubs/controllers/controller.method.update.stub
================================================
${{CLASS_VARIABLE}}->update($request->validated());

        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});


================================================
FILE: src/stubs/controllers/controller.stub
================================================
<?php

namespace {{NAMESPACE}};

use {{MODEL_NAMESPACE}};
use {{RESOURCE_NAMESPACE}};
use App\Http\Controllers\Controller;
use {{REQUEST_NAMESPACE}};
use {{RESOURCE_COLLECTION_NAMESPACE}};

class {{CONTROLLER_NAME}} extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        $this->authorize('viewAny', {{MODEL_CLASS}}::class);

        {{INDEX_METHOD}}
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store({{REQUEST_CLASS}} $request)
    {
        $this->authorize('create', {{MODEL_CLASS}}::class);

        {{STORE_METHOD}}
    }

    /**
     * Display the specified resource.
     */
    public function show({{MODEL_CLASS}} ${{MODEL_VARIABLE}})
    {
        $this->authorize('view', ${{MODEL_VARIABLE}});

        {{SHOW_METHOD}}
    }

    /**
     * Update the specified resource in storage.
     */
    public function update({{REQUEST_CLASS}} $request, {{MODEL_CLASS}} ${{MODEL_VARIABLE}})
    {
        $this->authorize('update', ${{MODEL_VARIABLE}});

        {{UPDATE_METHOD}}
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy({{MODEL_CLASS}} ${{MODEL_VARIABLE}})
    {
        $this->authorize('delete', ${{MODEL_VARIABLE}});

        {{DESTROY_METHOD}}
    }
}


================================================
FILE: src/stubs/factories/factory.stub
================================================
<?php

namespace Database\Factories;

use {{MODEL_NAMESPACE}}\{{MODEL_NAME}};
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\{{MODEL_NAMESPACE}}\{{MODEL_NAME}}>
 */
class {{CLASS_NAME}} extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
           'name' => $this->faker->name,
        ];
    }
}


================================================
FILE: src/stubs/migrations/migration.stub
================================================
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Schema table name to migrate
     */
    public $table = '{{TABLE_NAME}}';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists($this->table);
    }
};


================================================
FILE: src/stubs/models/model.stub
================================================
<?php

namespace {{NAMESPACE}};

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class {{CLASS_NAME}} extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name'
    ];

}


================================================
FILE: src/stubs/policies/api.policies.stub
================================================
<?php

namespace {{NAMESPACE}};

use {{MODEL_NAMESPACE}}\{{MODEL_CLASS}};
use {{MODEL_NAMESPACE}}\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class {{CLASS_NAME}}
{
    use HandlesAuthorization;

    /**
     * Determine whether the user can view any {{MODEL_VARIABLE}}.
     */
    public function viewAny(User $user): bool
    {
        //
    }

    /**
     * Determine whether the user can view the {{MODEL_VARIABLE}}.
     */
    public function view(User $user, {{MODEL_CLASS}} ${{MODEL_VARIABLE}}): bool
    {
        //
    }

    /**
     * Determine whether the user can create {{MODEL_VARIABLE}}.
     */
    public function create(User $user): bool
    {
        //
    }

    /**
     * Determine whether the user can update the {{MODEL_VARIABLE}}.
     */
    public function update(User $user, {{MODEL_CLASS}} ${{MODEL_VARIABLE}}): bool
    {
        //
    }

    /**
     * Determine whether the user can delete the {{MODEL_VARIABLE}}.
     */
    public function delete(User $user, {{MODEL_CLASS}} ${{MODEL_VARIABLE}}): bool
    {
        //
    }

    /**
     * Determine whether the user can restore the {{MODEL_VARIABLE}}.
     */
    public function restore(User $user, {{MODEL_CLASS}} ${{MODEL_VARIABLE}}): bool
    {
        //
    }

    /**
     * Determine whether the user can permanently delete the {{MODEL_VARIABLE}}.
     */
    public function forceDelete(User $user, {{MODEL_CLASS}} ${{MODEL_VARIABLE}}): bool
    {
        //
    }
}


================================================
FILE: src/stubs/requests/api.request.stub
================================================
<?php

namespace {{NAMESPACE}};

use Illuminate\Foundation\Http\FormRequest;

class {{CLASS_NAME}} extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'name' => ['required'],
        ];
    }
}


================================================
FILE: src/stubs/resources/api.collection.stub
================================================
<?php

namespace {{NAMESPACE}};

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

class {{CLASS_NAME}} extends ResourceCollection
{
    /**
     * The resource that this resource collects.
     *
     * @var string
     */
    public $collects = '{{RESOURCE_NAMESPACE}}\{{RESOURCE_CLASS_NAME}}';

    /**
     * Transform the resource collection into an array.
     *
     * @return array<int|string, mixed>
     */
    public function toArray(Request $request): array
    {
        return parent::toArray($request);
    }
}


================================================
FILE: src/stubs/resources/api.resource.stub
================================================
<?php

namespace {{NAMESPACE}};

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class {{CLASS_NAME}} extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return parent::toArray($request);
    }
}


================================================
FILE: src/stubs/routes/api.routes.stub
================================================
/*
|--------------------------------------------------------------------------
| {{MODEL_NAME}} endpoints
|--------------------------------------------------------------------------
 */
Route::name('{{ROUTE_NAME}}.')->controller({{CONTROLLER_NAME}}::class)->prefix('{{ROUTE_NAME}}')->group(function () {
    Route::get('/', 'index')->name('index');
    Route::post('/', 'store')->name('create');
    Route::get('/{{{MODEL_VARIABLE}}}', 'show')->name('show');
    Route::patch('/{{{MODEL_VARIABLE}}}', 'update')->name('update');
    Route::delete('/{{{MODEL_VARIABLE}}}', 'destroy')->name('destroy');
});


================================================
FILE: src/stubs/seeds/seed.stub
================================================
<?php

namespace Database\Seeders;

use {{MODEL_NAMESPACE}}\{{MODEL_NAME}};
use Illuminate\Database\Seeder;

class {{CLASS_NAME}} extends Seeder
{
    private $numberOf{{MODEL_PLURAL}} = 10;

    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->command->table(['{{MODEL_PLURAL}} table seeder notice'], [
            ['Edit this file to change the number of {{MODEL_PLURAL}} created'],
        ]);

        $this->command->info('Creating ' . $this->numberOf{{MODEL_PLURAL}} . ' {{MODEL_PLURAL}} ...');
        $bar = $this->command->getOutput()->createProgressBar($this->numberOf{{MODEL_PLURAL}});

        for ($i = 0; $i < $this->numberOf{{MODEL_PLURAL}}; ++$i) {
            {{MODEL_NAME}}::factory()->create();
            $bar->advance();
        }

        $bar->finish();
        $this->command->info('');
    }
}


================================================
FILE: tests/CollectionGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\CollectionGenerator;

class CollectionGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_filename()
    {
        $generator = new CollectionGenerator($this->model);
        $filename = $generator->fileName();
        $generator->handle();

        $this->assertEquals($filename, "{$generator->className()}.php");
    }

    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new CollectionGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, create_class_name($this->model, CollectionGenerator::class));
    }

    /** @test */
    public function it_creates_the_collection_file()
    {
        $generator = new CollectionGenerator($this->model);
        $config = namespace_path(config('laravel-resources.collections.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_collection_in_the_config_namespace()
    {
        config()->set('laravel-resources.collections.namespace', 'App\Http\Resources');
        $generator = new CollectionGenerator($this->model);

        $config = namespace_path(config('laravel-resources.collections.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_collection()
    {
        config()->set('laravel-resources.collections.suffix', $suffix = 'Suffix');
        config()->set('laravel-resources.collections.prefix', null);

        $generator = new CollectionGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$this->model}Collection{$suffix}", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_collection()
    {
        config()->set('laravel-resources.collections.suffix', null);
        config()->set('laravel-resources.collections.prefix', $prefix = 'PrefixAPI');

        $generator = new CollectionGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Collection", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_collection()
    {
        config()->set('laravel-resources.collections.prefix', $prefix = 'Foo');
        config()->set('laravel-resources.collections.suffix', $suffix = 'BarAPI');

        $generator = new CollectionGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Collection{$suffix}", $generator->className());
    }
}


================================================
FILE: tests/ControllerGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\ControllerGenerator;

class ControllerGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_filename()
    {
        $generator = new ControllerGenerator($this->model);
        $filename = $generator->fileName();
        $generator->handle();

        $this->assertEquals($filename, "{$generator->className()}.php");
    }

    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new ControllerGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, create_class_name($this->model, ControllerGenerator::class));
    }

    /** @test */
    public function it_creates_the_controller_file()
    {
        $generator = new ControllerGenerator($this->model);

        $config = namespace_path(config('laravel-resources.controllers.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_controller_in_the_config_namespace()
    {
        config()->set('laravel-resources.controllers.namespace', 'App\Http\Controllers\API');

        $generator = new ControllerGenerator($this->model);

        $config = namespace_path(config('laravel-resources.controllers.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_controller()
    {
        config()->set('laravel-resources.controllers.suffix', $suffix = 'Suffix');
        config()->set('laravel-resources.controllers.prefix', null);

        $generator = new ControllerGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$this->model}Controller{$suffix}", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_controller()
    {
        config()->set('laravel-resources.controllers.prefix', $prefix = 'Prefix');
        config()->set('laravel-resources.controllers.suffix', null);

        $generator = new ControllerGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Controller", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_controller()
    {
        config()->set('laravel-resources.controllers.prefix', $prefix = 'Foo');
        config()->set('laravel-resources.controllers.suffix', $suffix = 'BarAPI');

        $generator = new ControllerGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Controller{$suffix}", $generator->className());
    }
}


================================================
FILE: tests/FactoryGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\FactoryGenerator;

class FactoryGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new FactoryGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, 'UserFactory');
    }

    /** @test */
    public function it_creates_the_migration_file()
    {
        $generator = new FactoryGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.factories')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_migration_in_the_config_namespace()
    {
        config()->set('laravel-resources.database.factories', 'database/dummy');

        $generator = new FactoryGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.factories')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_migration_in_the_default_namespace()
    {
        $generator = new FactoryGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.factories')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }
}


================================================
FILE: tests/MigrationGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\MigrationGenerator;

class MigrationGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new MigrationGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, 'CreateUsersTable');
    }

    /** @test */
    public function it_creates_the_migration_file()
    {
        $generator = new MigrationGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.migrations')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_migration_in_the_config_namespace()
    {
        config()->set('laravel-resources.database.migrations', 'database/dummy');

        $generator = new MigrationGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.migrations')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_migration_in_the_default_namespace()
    {
        $generator = new MigrationGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.migrations')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }
}


================================================
FILE: tests/ModelGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\ModelGenerator;

class ModelGeneratorTest extends TestCase
{
    /**
     * Override to the model for this test suite.
     *
     * @var string
     */
    protected $model = 'Post';

    /** @test */
    public function it_creates_the_model_file()
    {
        $generator = new ModelGenerator($this->model);

        $config = namespace_path(config('laravel-resources.models.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_model_in_the_config_namespace()
    {
        config()->set('laravel-resources.models.namespace', 'App\Models');

        $generator = new ModelGenerator($this->model);

        $config = namespace_path(config('laravel-resources.models.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }
}


================================================
FILE: tests/PolicyGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\PolicyGenerator;

class PolicyGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_filename()
    {
        $generator = new PolicyGenerator($this->model);
        $filename = $generator->fileName();
        $generator->handle();

        $this->assertEquals($filename, "{$generator->className()}.php");
    }

    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new PolicyGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, create_class_name($this->model, PolicyGenerator::class));
    }

    /** @test */
    public function it_creates_the_policy_file()
    {
        $generator = new PolicyGenerator($this->model);

        $config = namespace_path(config('laravel-resources.policies.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_policy_in_the_config_namespace()
    {
        config()->set('laravel-resources.policies.namespace', 'App\Http\Policies');

        $generator = new PolicyGenerator($this->model);

        $config = namespace_path(config('laravel-resources.policies.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_policy()
    {
        config()->set('laravel-resources.policies.suffix', $suffix = 'Suffix');
        config()->set('laravel-resources.policies.prefix', null);

        $generator = new PolicyGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$this->model}Policy{$suffix}", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_policy()
    {
        config()->set('laravel-resources.policies.prefix', $prefix = 'Prefix');
        config()->set('laravel-resources.policies.suffix', null);

        $generator = new PolicyGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Policy", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_policy()
    {
        config()->set('laravel-resources.policies.prefix', $prefix = 'Foo');
        config()->set('laravel-resources.policies.suffix', $suffix = 'BarAPI');

        $generator = new PolicyGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Policy{$suffix}", $generator->className());
    }
}


================================================
FILE: tests/RequestGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\RequestGenerator;

class RequestGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_filename()
    {
        $generator = new RequestGenerator($this->model);
        $filename = $generator->fileName();
        $generator->handle();

        $this->assertEquals($filename, "{$generator->className()}.php");
    }

    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new RequestGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, create_class_name($this->model, RequestGenerator::class));
    }

    /** @test */
    public function it_creates_the_request_file()
    {
        $generator = new RequestGenerator($this->model);

        $config = namespace_path(config('laravel-resources.requests.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_request_in_the_config_namespace()
    {
        config()->set('laravel-resources.requests.namespace', 'App\Http');

        $generator = new RequestGenerator($this->model);

        $config = namespace_path(config('laravel-resources.requests.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_request()
    {
        config()->set('laravel-resources.requests.suffix', $suffix = 'Suffix');
        config()->set('laravel-resources.requests.prefix', null);

        $generator = new RequestGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$this->model}Request{$suffix}", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_request()
    {
        config()->set('laravel-resources.requests.prefix', $prefix = 'PrefixAPI');
        config()->set('laravel-resources.requests.suffix', null);

        $generator = new RequestGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Request", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_request()
    {
        config()->set('laravel-resources.requests.prefix', $prefix = 'Foo');
        config()->set('laravel-resources.requests.suffix', $suffix = 'BarAPI');

        $generator = new RequestGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Request{$suffix}", $generator->className());
    }
}


================================================
FILE: tests/ResourceCommandTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use Illuminate\Support\Facades\File;

class ResourceCommandTest extends TestCase
{
    /** @test */
    public function it_should_not_create_the_model_if_it_does_not_exists_and_the_user_deny_the_question()
    {
        $this->artisan('resources:create', ['model' => 'Foo'])
            ->expectsOutput('The model Foo does not exists.')
            ->expectsQuestion('Should I create it?', false);

        $this->assertFalse(File::exists(app_path('/Foo.php')));
    }

    /** @test */
    public function it_creates_the_model_if_it_does_not_exists_and_the_user_accepts_the_question()
    {
        $this->defaultQuestions();

        $path = namespace_path(config('laravel-resources.models.namespace').'\\Foo.php');

        $this->assertTrue(File::exists($path));
    }

    /** @test */
    public function it_creates_the_migration_when_the_response_to_the_question_is_true()
    {
        $this->defaultQuestions(['migration']);

        $this->assertEquals(1, collect(File::files(database_path('/migrations')))->count());
    }

    /** @test */
    public function it_creates_the_factory_when_the_response_to_the_question_is_true()
    {
        $this->defaultQuestions(['factory']);

        $this->assertEquals(1, collect(File::files(database_path('/factories')))->count());
    }

    /** @test */
    public function it_creates_the_seeder_when_the_response_to_the_question_is_true()
    {
        $this->defaultQuestions(['migration', 'factory', 'seeder']);

        $this->assertEquals(1, collect(File::files(database_path('/migrations')))->count());
        $this->assertEquals(1, collect(File::files(database_path('/seeders')))->count());
        $this->assertEquals(1, collect(File::files(database_path('/factories')))->count());
    }

    /** @test */
    public function it_creates_the_all_files_when_the_response_to_the_question_is_always_true()
    {
        $this->defaultQuestions(['seeder']);

        $this->assertEquals(1, collect(File::files(database_path('/seeders')))->count());
    }

    /**
     * Create the command boilerplate for the model creation.
     *
     * @return void
     */
    protected function defaultQuestions($args = [], $shouldCreate = true)
    {
        $this->artisan('resources:create', ['model' => 'Foo'])
            ->expectsOutput('The model Foo does not exists.')
            ->expectsQuestion('Should I create it?', $shouldCreate)
            ->expectsQuestion('Should I create the migration for Foo?', in_array('migration', $args))
            ->expectsQuestion('Should I create the factory for Foo?', in_array('factory', $args))
            ->expectsQuestion('Should I create the seeder for Foo?', in_array('seeder', $args));
    }
}


================================================
FILE: tests/ResourceGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\ResourceGenerator;

class ResourceGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_filename()
    {
        $generator = new ResourceGenerator($this->model);
        $filename = $generator->fileName();
        $generator->handle();

        $this->assertEquals($filename, "{$generator->className()}.php");
    }

    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new ResourceGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, create_class_name($this->model, ResourceGenerator::class));
    }

    /** @test */
    public function it_creates_the_resource_file()
    {
        $generator = new ResourceGenerator($this->model);

        $config = namespace_path(config('laravel-resources.resources.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_request_in_the_config_namespace()
    {
        config()->set('laravel-resources.resources.namespace', 'App\Http');

        $generator = new ResourceGenerator($this->model);

        $config = namespace_path(config('laravel-resources.resources.namespace')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_resource()
    {
        config()->set('laravel-resources.resources.suffix', $suffix = 'Suffix');
        config()->set('laravel-resources.resources.prefix', null);

        $generator = new ResourceGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$this->model}Resource{$suffix}", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_resource()
    {
        config()->set('laravel-resources.resources.prefix', $prefix = 'Prefix');
        config()->set('laravel-resources.resources.suffix', null);

        $generator = new ResourceGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Resource", $generator->className());
    }

    /** @test */
    public function it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_resource()
    {
        config()->set('laravel-resources.resources.prefix', $prefix = 'Foo');
        config()->set('laravel-resources.resources.suffix', $suffix = 'BarAPI');

        $generator = new ResourceGenerator($this->model);
        $generator->handle();

        $this->assertEquals("{$prefix}{$this->model}Resource{$suffix}", $generator->className());
    }
}


================================================
FILE: tests/SeederGeneratorTest.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use tiagomichaelsousa\LaravelResources\Generators\SeederGenerator;

class SeederGeneratorTest extends TestCase
{
    /** @test */
    public function it_generates_the_right_class_name()
    {
        $generator = new SeederGenerator($this->model);
        $filename = $generator->className();
        $generator->handle();

        $this->assertEquals($filename, 'UsersTableSeeder');
    }

    /** @test */
    public function it_creates_the_seeder_file()
    {
        $generator = new SeederGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.seeds')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_seeder_in_the_config_namespace()
    {
        config()->set('laravel-resources.database.seeds', 'database/dummy');

        $generator = new SeederGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.seeds')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }

    /** @test */
    public function it_creates_the_seeder_in_the_default_namespace()
    {
        $generator = new SeederGenerator($this->model);

        $config = namespace_path(config('laravel-resources.database.seeds')."\\{$generator->fileName()}");

        $generator->handle();

        $this->assertFileExists($config);
    }
}


================================================
FILE: tests/TestCase.php
================================================
<?php

namespace tiagomichaelsousa\LaravelResources\Tests;

use Illuminate\Support\Facades\File;
use Orchestra\Testbench\TestCase as Orchestra;
use tiagomichaelsousa\LaravelResources\LaravelResourcesServiceProvider;

abstract class TestCase extends Orchestra
{
    /**
     * Default model to run the test suite.
     *
     * @var string
     */
    protected $model = 'User';

    /**
     * Setup the test environment.
     *
     * @return void
     */
    protected function setUp(): void
    {
        parent::setUp();

        $this->clearDirectories();

        $this->initialize();
    }

    /**
     * Clean up the testing environment before the next test.
     *
     * @return void
     */
    protected function tearDown(): void
    {
        parent::tearDown();
    }

    /**
     * Clean up the testing environment directories before the next test.
     *
     * @return void
     */
    private function clearDirectories()
    {
        File::cleanDirectory(base_path('app'));
        File::deleteDirectory(base_path('routes'));
        File::cleanDirectory(database_path('migrations'));
        File::cleanDirectory(database_path('factories'));
        File::cleanDirectory(database_path('seeders'));
        File::cleanDirectory(database_path('dummy'));
    }

    /**
     * Create the test suite default folder structure.
     *
     * @return void
     */
    private function initialize()
    {
        if (! File::exists(namespace_path(config('laravel-resources.models.namespace')).'/User.php')) {
            $this->artisan('make:model User');
        }

        if (! File::exists($route = namespace_path(config('laravel-resources.routes.path')).'/'.config('laravel-resources.routes.filename'))) {
            make_directory(namespace_path(config('laravel-resources.routes.path')));
            file_put_contents($route, '<?php');
        }
    }

    /**
     * Create the test suite default folder structure.
     *
     * @return void
     */
    protected function getPackageProviders($app)
    {
        return [
            LaravelResourcesServiceProvider::class,
        ];
    }
}
Download .txt
gitextract_vkyfqi4p/

├── .all-contributorsrc
├── .github/
│   └── workflows/
│       ├── composer-normalize.yml
│       └── run-tests.yml
├── .gitignore
├── .styleci.yml
├── README.md
├── changelog.md
├── code_of_conduct.md
├── composer.json
├── config/
│   └── laravel-resources.php
├── contributing.md
├── license.md
├── phpunit.xml
├── src/
│   ├── Commands/
│   │   └── ResourceCommand.php
│   ├── Exceptions/
│   │   └── File.php
│   ├── Generators/
│   │   ├── AbstractGenerator.php
│   │   ├── CollectionGenerator.php
│   │   ├── ControllerGenerator.php
│   │   ├── FactoryGenerator.php
│   │   ├── Generator.php
│   │   ├── MigrationGenerator.php
│   │   ├── ModelGenerator.php
│   │   ├── PolicyGenerator.php
│   │   ├── RequestGenerator.php
│   │   ├── ResourceGenerator.php
│   │   ├── RouteGenerator.php
│   │   └── SeederGenerator.php
│   ├── Helpers/
│   │   └── helpers.php
│   ├── LaravelResourcesServiceProvider.php
│   └── stubs/
│       ├── controllers/
│       │   ├── controller.method.destroy.stub
│       │   ├── controller.method.index.stub
│       │   ├── controller.method.show.stub
│       │   ├── controller.method.store.stub
│       │   ├── controller.method.update.stub
│       │   └── controller.stub
│       ├── factories/
│       │   └── factory.stub
│       ├── migrations/
│       │   └── migration.stub
│       ├── models/
│       │   └── model.stub
│       ├── policies/
│       │   └── api.policies.stub
│       ├── requests/
│       │   └── api.request.stub
│       ├── resources/
│       │   ├── api.collection.stub
│       │   └── api.resource.stub
│       ├── routes/
│       │   └── api.routes.stub
│       └── seeds/
│           └── seed.stub
└── tests/
    ├── CollectionGeneratorTest.php
    ├── ControllerGeneratorTest.php
    ├── FactoryGeneratorTest.php
    ├── MigrationGeneratorTest.php
    ├── ModelGeneratorTest.php
    ├── PolicyGeneratorTest.php
    ├── RequestGeneratorTest.php
    ├── ResourceCommandTest.php
    ├── ResourceGeneratorTest.php
    ├── SeederGeneratorTest.php
    └── TestCase.php
Download .txt
SYMBOL INDEX (157 symbols across 27 files)

FILE: src/Commands/ResourceCommand.php
  class ResourceCommand (line 18) | class ResourceCommand extends Command
    method modelExists (line 72) | private function modelExists()
    method createModelResources (line 82) | private function createModelResources()
    method createResources (line 96) | private function createResources()
    method handle (line 124) | public function handle()

FILE: src/Exceptions/File.php
  class File (line 7) | class File extends Exception
    method alreadyExistsInDirectory (line 9) | public static function alreadyExistsInDirectory(string $path)
    method doesNotExists (line 14) | public static function doesNotExists(string $path)

FILE: src/Generators/AbstractGenerator.php
  class AbstractGenerator (line 8) | abstract class AbstractGenerator implements Generator
    method __construct (line 22) | public function __construct($model)
    method directoryExists (line 32) | public function directoryExists($path)
    method fileAlreadyExists (line 42) | public function fileAlreadyExists($path)
    method fileName (line 54) | public function fileName()

FILE: src/Generators/CollectionGenerator.php
  class CollectionGenerator (line 7) | class CollectionGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 39) | public function className()
    method handle (line 49) | public function handle()

FILE: src/Generators/ControllerGenerator.php
  class ControllerGenerator (line 8) | class ControllerGenerator extends AbstractGenerator
    method getStub (line 15) | public function getStub()
    method replacements (line 25) | public function replacements()
    method methodsReplacements (line 47) | private function methodsReplacements()
    method modelReplacements (line 73) | public function modelReplacements()
    method requestReplacements (line 87) | public function requestReplacements()
    method className (line 102) | public function className()
    method handle (line 112) | public function handle()

FILE: src/Generators/FactoryGenerator.php
  class FactoryGenerator (line 7) | class FactoryGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 38) | public function className()
    method handle (line 48) | public function handle()

FILE: src/Generators/Generator.php
  type Generator (line 5) | interface Generator
    method getStub (line 7) | public function getStub();
    method replacements (line 9) | public function replacements();
    method fileAlreadyExists (line 11) | public function fileAlreadyExists($path);
    method directoryExists (line 13) | public function directoryExists($path);
    method className (line 15) | public function className();
    method fileName (line 17) | public function fileName();
    method handle (line 19) | public function handle();

FILE: src/Generators/MigrationGenerator.php
  class MigrationGenerator (line 9) | class MigrationGenerator extends AbstractGenerator
    method getStub (line 16) | public function getStub()
    method replacements (line 26) | public function replacements()
    method className (line 39) | public function className()
    method fileName (line 51) | public function fileName()
    method handle (line 64) | public function handle()

FILE: src/Generators/ModelGenerator.php
  class ModelGenerator (line 7) | class ModelGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 37) | public function className()
    method handle (line 47) | public function handle()

FILE: src/Generators/PolicyGenerator.php
  class PolicyGenerator (line 7) | class PolicyGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 41) | public function className()
    method handle (line 51) | public function handle()

FILE: src/Generators/RequestGenerator.php
  class RequestGenerator (line 7) | class RequestGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 37) | public function className()
    method handle (line 47) | public function handle()

FILE: src/Generators/ResourceGenerator.php
  class ResourceGenerator (line 7) | class ResourceGenerator extends AbstractGenerator
    method getStub (line 14) | public function getStub()
    method replacements (line 24) | public function replacements()
    method className (line 37) | public function className()
    method handle (line 47) | public function handle()

FILE: src/Generators/RouteGenerator.php
  class RouteGenerator (line 9) | class RouteGenerator extends AbstractGenerator
    method getStub (line 16) | public function getStub()
    method replacements (line 26) | public function replacements()
    method fileAlreadyExists (line 41) | public function fileAlreadyExists($path)
    method className (line 53) | public function className()
    method fileName (line 63) | public function fileName()
    method handle (line 73) | public function handle()
    method generateControllerName (line 99) | private function generateControllerName()

FILE: src/Generators/SeederGenerator.php
  class SeederGenerator (line 8) | class SeederGenerator extends AbstractGenerator
    method getStub (line 15) | public function getStub()
    method replacements (line 25) | public function replacements()
    method className (line 40) | public function className()
    method handle (line 52) | public function handle()

FILE: src/Helpers/helpers.php
  function make_directory (line 16) | function make_directory($path, int $mode = 0755, bool $recursive = true,...
  function namespace_path (line 29) | function namespace_path($path)
  function create_class_name (line 42) | function create_class_name($model, $resource)

FILE: src/LaravelResourcesServiceProvider.php
  class LaravelResourcesServiceProvider (line 7) | class LaravelResourcesServiceProvider extends ServiceProvider
    method boot (line 23) | public function boot()
    method register (line 36) | public function register()
    method bootForConsole (line 46) | protected function bootForConsole()

FILE: tests/CollectionGeneratorTest.php
  class CollectionGeneratorTest (line 7) | class CollectionGeneratorTest extends TestCase
    method it_generates_the_right_filename (line 10) | public function it_generates_the_right_filename()
    method it_generates_the_right_class_name (line 20) | public function it_generates_the_right_class_name()
    method it_creates_the_collection_file (line 30) | public function it_creates_the_collection_file()
    method it_creates_the_collection_in_the_config_namespace (line 41) | public function it_creates_the_collection_in_the_config_namespace()
    method it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_collection (line 54) | public function it_generates_the_name_with_the_suffix_defined_in_the_c...
    method it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_collection (line 66) | public function it_generates_the_name_with_the_prefix_defined_in_the_c...
    method it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_collection (line 78) | public function it_generates_the_name_with_the_suffix_and_prefix_defin...

FILE: tests/ControllerGeneratorTest.php
  class ControllerGeneratorTest (line 7) | class ControllerGeneratorTest extends TestCase
    method it_generates_the_right_filename (line 10) | public function it_generates_the_right_filename()
    method it_generates_the_right_class_name (line 20) | public function it_generates_the_right_class_name()
    method it_creates_the_controller_file (line 30) | public function it_creates_the_controller_file()
    method it_creates_the_controller_in_the_config_namespace (line 42) | public function it_creates_the_controller_in_the_config_namespace()
    method it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_controller (line 56) | public function it_generates_the_name_with_the_suffix_defined_in_the_c...
    method it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_controller (line 68) | public function it_generates_the_name_with_the_prefix_defined_in_the_c...
    method it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_controller (line 80) | public function it_generates_the_name_with_the_suffix_and_prefix_defin...

FILE: tests/FactoryGeneratorTest.php
  class FactoryGeneratorTest (line 7) | class FactoryGeneratorTest extends TestCase
    method it_generates_the_right_class_name (line 10) | public function it_generates_the_right_class_name()
    method it_creates_the_migration_file (line 20) | public function it_creates_the_migration_file()
    method it_creates_the_migration_in_the_config_namespace (line 32) | public function it_creates_the_migration_in_the_config_namespace()
    method it_creates_the_migration_in_the_default_namespace (line 46) | public function it_creates_the_migration_in_the_default_namespace()

FILE: tests/MigrationGeneratorTest.php
  class MigrationGeneratorTest (line 7) | class MigrationGeneratorTest extends TestCase
    method it_generates_the_right_class_name (line 10) | public function it_generates_the_right_class_name()
    method it_creates_the_migration_file (line 20) | public function it_creates_the_migration_file()
    method it_creates_the_migration_in_the_config_namespace (line 32) | public function it_creates_the_migration_in_the_config_namespace()
    method it_creates_the_migration_in_the_default_namespace (line 46) | public function it_creates_the_migration_in_the_default_namespace()

FILE: tests/ModelGeneratorTest.php
  class ModelGeneratorTest (line 7) | class ModelGeneratorTest extends TestCase
    method it_creates_the_model_file (line 17) | public function it_creates_the_model_file()
    method it_creates_the_model_in_the_config_namespace (line 29) | public function it_creates_the_model_in_the_config_namespace()

FILE: tests/PolicyGeneratorTest.php
  class PolicyGeneratorTest (line 7) | class PolicyGeneratorTest extends TestCase
    method it_generates_the_right_filename (line 10) | public function it_generates_the_right_filename()
    method it_generates_the_right_class_name (line 20) | public function it_generates_the_right_class_name()
    method it_creates_the_policy_file (line 30) | public function it_creates_the_policy_file()
    method it_creates_the_policy_in_the_config_namespace (line 42) | public function it_creates_the_policy_in_the_config_namespace()
    method it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_policy (line 56) | public function it_generates_the_name_with_the_suffix_defined_in_the_c...
    method it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_policy (line 68) | public function it_generates_the_name_with_the_prefix_defined_in_the_c...
    method it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_policy (line 80) | public function it_generates_the_name_with_the_suffix_and_prefix_defin...

FILE: tests/RequestGeneratorTest.php
  class RequestGeneratorTest (line 7) | class RequestGeneratorTest extends TestCase
    method it_generates_the_right_filename (line 10) | public function it_generates_the_right_filename()
    method it_generates_the_right_class_name (line 20) | public function it_generates_the_right_class_name()
    method it_creates_the_request_file (line 30) | public function it_creates_the_request_file()
    method it_creates_the_request_in_the_config_namespace (line 42) | public function it_creates_the_request_in_the_config_namespace()
    method it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_request (line 56) | public function it_generates_the_name_with_the_suffix_defined_in_the_c...
    method it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_request (line 68) | public function it_generates_the_name_with_the_prefix_defined_in_the_c...
    method it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_request (line 80) | public function it_generates_the_name_with_the_suffix_and_prefix_defin...

FILE: tests/ResourceCommandTest.php
  class ResourceCommandTest (line 7) | class ResourceCommandTest extends TestCase
    method it_should_not_create_the_model_if_it_does_not_exists_and_the_user_deny_the_question (line 10) | public function it_should_not_create_the_model_if_it_does_not_exists_a...
    method it_creates_the_model_if_it_does_not_exists_and_the_user_accepts_the_question (line 20) | public function it_creates_the_model_if_it_does_not_exists_and_the_use...
    method it_creates_the_migration_when_the_response_to_the_question_is_true (line 30) | public function it_creates_the_migration_when_the_response_to_the_ques...
    method it_creates_the_factory_when_the_response_to_the_question_is_true (line 38) | public function it_creates_the_factory_when_the_response_to_the_questi...
    method it_creates_the_seeder_when_the_response_to_the_question_is_true (line 46) | public function it_creates_the_seeder_when_the_response_to_the_questio...
    method it_creates_the_all_files_when_the_response_to_the_question_is_always_true (line 56) | public function it_creates_the_all_files_when_the_response_to_the_ques...
    method defaultQuestions (line 68) | protected function defaultQuestions($args = [], $shouldCreate = true)

FILE: tests/ResourceGeneratorTest.php
  class ResourceGeneratorTest (line 7) | class ResourceGeneratorTest extends TestCase
    method it_generates_the_right_filename (line 10) | public function it_generates_the_right_filename()
    method it_generates_the_right_class_name (line 20) | public function it_generates_the_right_class_name()
    method it_creates_the_resource_file (line 30) | public function it_creates_the_resource_file()
    method it_creates_the_request_in_the_config_namespace (line 42) | public function it_creates_the_request_in_the_config_namespace()
    method it_generates_the_name_with_the_suffix_defined_in_the_configuration_file_for_the_resource (line 56) | public function it_generates_the_name_with_the_suffix_defined_in_the_c...
    method it_generates_the_name_with_the_prefix_defined_in_the_configuration_file_for_the_resource (line 68) | public function it_generates_the_name_with_the_prefix_defined_in_the_c...
    method it_generates_the_name_with_the_suffix_and_prefix_defined_in_the_configuration_file_for_the_resource (line 80) | public function it_generates_the_name_with_the_suffix_and_prefix_defin...

FILE: tests/SeederGeneratorTest.php
  class SeederGeneratorTest (line 7) | class SeederGeneratorTest extends TestCase
    method it_generates_the_right_class_name (line 10) | public function it_generates_the_right_class_name()
    method it_creates_the_seeder_file (line 20) | public function it_creates_the_seeder_file()
    method it_creates_the_seeder_in_the_config_namespace (line 32) | public function it_creates_the_seeder_in_the_config_namespace()
    method it_creates_the_seeder_in_the_default_namespace (line 46) | public function it_creates_the_seeder_in_the_default_namespace()

FILE: tests/TestCase.php
  class TestCase (line 9) | abstract class TestCase extends Orchestra
    method setUp (line 23) | protected function setUp(): void
    method tearDown (line 37) | protected function tearDown(): void
    method clearDirectories (line 47) | private function clearDirectories()
    method initialize (line 62) | private function initialize()
    method getPackageProviders (line 79) | protected function getPackageProviders($app)
Condensed preview — 55 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (87K chars).
[
  {
    "path": ".all-contributorsrc",
    "chars": 1372,
    "preview": "{\n  \"files\": [\n    \"README.md\"\n  ],\n  \"imageSize\": 100,\n  \"commit\": false,\n  \"contributors\": [\n    {\n      \"login\": \"Raf"
  },
  {
    "path": ".github/workflows/composer-normalize.yml",
    "chars": 537,
    "preview": "name: Composer Normalize\n\non:\n    push:\n        paths:\n            - \"composer.json\"\n\njobs:\n    normalize:\n        runs-"
  },
  {
    "path": ".github/workflows/run-tests.yml",
    "chars": 1612,
    "preview": "name: CI\n\non: ['push', 'pull_request']\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    strategy:\n      fail-fast: false\n"
  },
  {
    "path": ".gitignore",
    "chars": 120,
    "preview": "/.phpunit.result.cache\n/build/\n/vendor/\n/tests/temp\ncomposer.lock\ncomposer.phar\n.idea\n/report\n.DS_Store\ncoverage.clover\n"
  },
  {
    "path": ".styleci.yml",
    "chars": 53,
    "preview": "preset: laravel\n\nfinder:\n    name:\n        - \"*.php\"\n"
  },
  {
    "path": "README.md",
    "chars": 6013,
    "preview": "# Laravel Resources\n\n<p align=\"center\">\n    <img src=\"./docs/demo.gif\" alt=\"Laravel Resources Demo\" width=\"480\">\n</p>\n\n<"
  },
  {
    "path": "changelog.md",
    "chars": 128,
    "preview": "# Changelog\n\nAll notable changes to `LaravelResources` will be documented in this file.\n\n## Version 1.0\n\n### Added\n- Eve"
  },
  {
    "path": "code_of_conduct.md",
    "chars": 537,
    "preview": "# Code Of Conductd\n\nThis code of conduct is derived from the Ruby code of conduct. Any violations of the code of conduct"
  },
  {
    "path": "composer.json",
    "chars": 1496,
    "preview": "{\n  \"name\": \"tiagomichaelsousa/laravelresources\",\n  \"description\": \"Laravel Resources is a speed-up development package "
  },
  {
    "path": "config/laravel-resources.php",
    "chars": 4418,
    "preview": "<?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Controller"
  },
  {
    "path": "contributing.md",
    "chars": 1152,
    "preview": "# Contributing\n\nContributions are welcome and will be fully credited.\n\nContributions are accepted via Pull Requests on ["
  },
  {
    "path": "license.md",
    "chars": 1113,
    "preview": "# The license\n\nCopyright 2020 [@tiagomichaelsousa](https://github.com/tiagomichaelsousa)\n\nPermission is hereby granted, "
  },
  {
    "path": "phpunit.xml",
    "chars": 677,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" bootstrap=\"vendor/"
  },
  {
    "path": "src/Commands/ResourceCommand.php",
    "chars": 3927,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Fa"
  },
  {
    "path": "src/Exceptions/File.php",
    "chars": 404,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Exceptions;\n\nuse Exception;\n\nclass File extends Exception\n{\n    publ"
  },
  {
    "path": "src/Generators/AbstractGenerator.php",
    "chars": 1224,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\nuse tiagomichaelso"
  },
  {
    "path": "src/Generators/CollectionGenerator.php",
    "chars": 1652,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass CollectionG"
  },
  {
    "path": "src/Generators/ControllerGenerator.php",
    "chars": 3859,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Arr;\nuse Illuminate\\Support\\Faca"
  },
  {
    "path": "src/Generators/FactoryGenerator.php",
    "chars": 1467,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass FactoryGene"
  },
  {
    "path": "src/Generators/Generator.php",
    "chars": 347,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\ninterface Generator\n{\n    public function getStub();\n\n "
  },
  {
    "path": "src/Generators/MigrationGenerator.php",
    "chars": 1786,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Carbon\\Carbon;\nuse Illuminate\\Support\\Facades\\File;"
  },
  {
    "path": "src/Generators/ModelGenerator.php",
    "chars": 1398,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass ModelGenera"
  },
  {
    "path": "src/Generators/PolicyGenerator.php",
    "chars": 1712,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass PolicyGener"
  },
  {
    "path": "src/Generators/RequestGenerator.php",
    "chars": 1442,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass RequestGene"
  },
  {
    "path": "src/Generators/ResourceGenerator.php",
    "chars": 1451,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass ResourceGen"
  },
  {
    "path": "src/Generators/RouteGenerator.php",
    "chars": 2628,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\nuse Illuminate\\Sup"
  },
  {
    "path": "src/Generators/SeederGenerator.php",
    "chars": 1589,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Generators;\n\nuse Illuminate\\Support\\Facades\\File;\nuse Illuminate\\Sup"
  },
  {
    "path": "src/Helpers/helpers.php",
    "chars": 1517,
    "preview": "<?php\n\nuse Illuminate\\Support\\Facades\\File;\nuse Illuminate\\Support\\Str;\n\nif (! function_exists('make_directory')) {\n    "
  },
  {
    "path": "src/LaravelResourcesServiceProvider.php",
    "chars": 1266,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources;\n\nuse Illuminate\\Support\\ServiceProvider;\n\nclass LaravelResourcesSer"
  },
  {
    "path": "src/stubs/controllers/controller.method.destroy.stub",
    "chars": 91,
    "preview": "${{CLASS_VARIABLE}}->delete();\n\n        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});\n"
  },
  {
    "path": "src/stubs/controllers/controller.method.index.stub",
    "chars": 105,
    "preview": "${{CLASS_VARIABLE}} = {{CLASS_NAME}}::all();\n\n        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});\n"
  },
  {
    "path": "src/stubs/controllers/controller.method.show.stub",
    "chars": 51,
    "preview": "return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});\n"
  },
  {
    "path": "src/stubs/controllers/controller.method.store.stub",
    "chars": 129,
    "preview": "${{CLASS_VARIABLE}} = {{CLASS_NAME}}::create($request->validated());\n\n        return new {{RESOURCE_NAME}}(${{CLASS_VARI"
  },
  {
    "path": "src/stubs/controllers/controller.method.update.stub",
    "chars": 112,
    "preview": "${{CLASS_VARIABLE}}->update($request->validated());\n\n        return new {{RESOURCE_NAME}}(${{CLASS_VARIABLE}});\n"
  },
  {
    "path": "src/stubs/controllers/controller.stub",
    "chars": 1337,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse {{MODEL_NAMESPACE}};\nuse {{RESOURCE_NAMESPACE}};\nuse App\\Http\\Controllers\\Controlle"
  },
  {
    "path": "src/stubs/factories/factory.stub",
    "chars": 498,
    "preview": "<?php\n\nnamespace Database\\Factories;\n\nuse {{MODEL_NAMESPACE}}\\{{MODEL_NAME}};\nuse Illuminate\\Database\\Eloquent\\Factories"
  },
  {
    "path": "src/stubs/migrations/migration.stub",
    "chars": 664,
    "preview": "<?php\n\nuse Illuminate\\Support\\Facades\\Schema;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migratio"
  },
  {
    "path": "src/stubs/models/model.stub",
    "chars": 329,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasF"
  },
  {
    "path": "src/stubs/policies/api.policies.stub",
    "chars": 1482,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse {{MODEL_NAMESPACE}}\\{{MODEL_CLASS}};\nuse {{MODEL_NAMESPACE}}\\User;\nuse Illuminate\\A"
  },
  {
    "path": "src/stubs/requests/api.request.stub",
    "chars": 560,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass {{CLASS_NAME}} extends FormRequest\n{"
  },
  {
    "path": "src/stubs/resources/api.collection.stub",
    "chars": 561,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\ResourceCollection;\n\ncl"
  },
  {
    "path": "src/stubs/resources/api.resource.stub",
    "chars": 369,
    "preview": "<?php\n\nnamespace {{NAMESPACE}};\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass {{"
  },
  {
    "path": "src/stubs/routes/api.routes.stub",
    "chars": 604,
    "preview": "/*\n|--------------------------------------------------------------------------\n| {{MODEL_NAME}} endpoints\n|-------------"
  },
  {
    "path": "src/stubs/seeds/seed.stub",
    "chars": 867,
    "preview": "<?php\n\nnamespace Database\\Seeders;\n\nuse {{MODEL_NAMESPACE}}\\{{MODEL_NAME}};\nuse Illuminate\\Database\\Seeder;\n\nclass {{CLA"
  },
  {
    "path": "tests/CollectionGeneratorTest.php",
    "chars": 3035,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\Collection"
  },
  {
    "path": "tests/ControllerGeneratorTest.php",
    "chars": 3040,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\Controller"
  },
  {
    "path": "tests/FactoryGeneratorTest.php",
    "chars": 1546,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\FactoryGen"
  },
  {
    "path": "tests/MigrationGeneratorTest.php",
    "chars": 1567,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\MigrationG"
  },
  {
    "path": "tests/ModelGeneratorTest.php",
    "chars": 1025,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\ModelGener"
  },
  {
    "path": "tests/PolicyGeneratorTest.php",
    "chars": 2934,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\PolicyGene"
  },
  {
    "path": "tests/RequestGeneratorTest.php",
    "chars": 2946,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\RequestGen"
  },
  {
    "path": "tests/ResourceCommandTest.php",
    "chars": 2757,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse Illuminate\\Support\\Facades\\File;\n\nclass ResourceCommandT"
  },
  {
    "path": "tests/ResourceGeneratorTest.php",
    "chars": 2969,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\ResourceGe"
  },
  {
    "path": "tests/SeederGeneratorTest.php",
    "chars": 1520,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse tiagomichaelsousa\\LaravelResources\\Generators\\SeederGene"
  },
  {
    "path": "tests/TestCase.php",
    "chars": 2116,
    "preview": "<?php\n\nnamespace tiagomichaelsousa\\LaravelResources\\Tests;\n\nuse Illuminate\\Support\\Facades\\File;\nuse Orchestra\\Testbench"
  }
]

About this extraction

This page contains the full source code of the tiagomichaelsousa/LaravelResources GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 55 files (78.2 KB), approximately 19.9k tokens, and a symbol index with 157 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!