koel/app/Repositories/Contracts/RepositoryInterface.php

33 lines
835 B
PHP
Raw Normal View History

2018-08-29 06:15:11 +00:00
<?php
namespace App\Repositories\Contracts;
2018-08-29 06:15:11 +00:00
2024-10-15 06:29:31 +00:00
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
2018-08-29 06:15:11 +00:00
use Illuminate\Database\Eloquent\Model;
2022-07-27 15:32:36 +00:00
use Illuminate\Support\Collection;
2018-08-29 06:15:11 +00:00
2024-10-15 06:29:31 +00:00
/** @template T of Model */
2018-08-29 06:15:11 +00:00
interface RepositoryInterface
{
2024-10-15 06:29:31 +00:00
/** @return T */
public function getOne($id): Model;
2024-10-15 06:29:31 +00:00
/** @return T */
public function getOneBy(array $params): Model;
/** @return T|null */
public function findOne($id): ?Model;
2018-08-29 06:15:11 +00:00
2024-10-15 06:29:31 +00:00
/** @return T|null */
public function findOneBy(array $params): ?Model;
/** @return Collection<array-key, T> */
public function getMany(array $ids, bool $preserveOrder = false): Collection;
2018-08-29 06:15:11 +00:00
2024-10-15 06:29:31 +00:00
/** @return Collection<int, T> */
public function getAll(): EloquentCollection;
/** @return T|null */
public function findFirstWhere(...$params): ?Model;
2018-08-29 06:15:11 +00:00
}