New-Thanasoft/thanasoft-back/app/Repositories/BaseRepositoryInterface.php

53 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Repositories;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
/**
* Base repository contract for simple CRUD operations using Eloquent models.
*/
interface BaseRepositoryInterface
{
/**
* Get all records.
*
* @param array<int, string> $columns
* @return Collection<int, Model>
*/
public function all(array $columns = ['*']): Collection;
/**
* Find a record by its primary key.
*
* @param int|string $id
* @param array<int, string> $columns
*/
public function find(int|string $id, array $columns = ['*']): ?Model;
/**
* Create a new record with the given attributes.
*
* @param array<string, mixed> $attributes
*/
public function create(array $attributes): Model;
/**
* Update an existing record by id with the given attributes.
*
* @param int|string $id
* @param array<string, mixed> $attributes
*/
public function update(int|string $id, array $attributes): bool;
/**
* Delete a record by its primary key.
*
* @param int|string $id
*/
public function delete(int|string $id): bool;
}