PHP code example of oscabrera / model-repository

1. Go to this page and download the library: Download oscabrera/model-repository library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oscabrera / model-repository example snippets


#[Get(uri: 'models/{id}', name: 'models.read')]
public function read(string $id): JsonResponse
{
    return response()->json($this->service->read($id));
}

protected $hidden = [
        'id',
    ];
shell
php artisan migrate

├── app
│   ├── Contracts
│   │   ├── Repositories
│   │   │   └── Name
│   │   │       └── INameRepository.php
│   │   └── Services
│   │       └── Name
│   │           └── INameService.php
│   ├── Http
│   │   ├── Controllers
│   │   │     └── Name
│   │   │         └── NameController.php
│   │   └── Requests
│   │         └── Name
│   │             └── NameRequest.php
│   ├── Models
│   │   └── Name
│   │       └── Name.php
│   ├── Repositories
│   │   └── Name
│   │       └── NameRepository.php
│   └── Services
│       └── Name
│           └── NameService.php
├── database
│   ├── migrations
│   │   └── 2024_03_17_022718_create_names_table.php
│   ├── Seeders
│   │   └── NameSeeder.php
│   └── Factories
│       └── DummyModel
│           └── DummyModelFactory.php