<?php

namespace App\Classes\Modules\Companies\Services;


use App\Models\Company;
use App\Http\Resources\Company as CompanyResource;

class ListsCompany
{

    /** @var  Company */
    private $repository;

    /**
     * ListsCompany constructor.
     * @param Company $repository
     */
    public function __construct(Company $repository)
    {
        $this->repository = $repository;
    }


    public function execute(bool $pagination){

        $companies = $pagination ? $this->repository->orderBy('created_at')->paginate(10) : $this->repository->orderBy('created_at')->get();

        return CompanyResource::collection($companies);

    }
}