PHP code example of manchenkoff / laravel-repositories

1. Go to this page and download the library: Download manchenkoff/laravel-repositories 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/ */

    

manchenkoff / laravel-repositories example snippets


'providers' => ServiceProvider::defaultProviders()
    ->merge([
        // Package Service Providers
        \Manchenkoff\Laravel\Repositories\ServiceProvider::class,

        // Application Service Providers
        // ...
    ])
    ->toArray(),



namespace App\Services;

use Illuminate\Database\Eloquent\Collection;
use App\Contracts\Repositories\PostRepositoryInterface;
use App\Contracts\Services\PostServiceInterface;

final class PostService implements PostServiceInterface
{
    private readonly PostRepositoryInterface $repository;

    public function __construct(PostRepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    public function getAllPosts(): Collection
    {
        return $this->repository->all();
    }
}

protected function query(): Builder
{
    return parent::query()->with('comments')->orderBy('created_at', 'desc');
}
bash
php artisan make:model Post
bash
php artisan vendor:publish --provider="Manchenkoff\Laravel\Repositories\ServiceProvider"