init commit
This commit is contained in:
156
app/Interfaces/BaseRepositoryInterface.php
Normal file
156
app/Interfaces/BaseRepositoryInterface.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Base Repository Interface
|
||||
*
|
||||
* Defines the contract for all repository implementations.
|
||||
* Provides a consistent API for data access operations.
|
||||
*
|
||||
* @author David Valera Melendez <david@valera-melendez.de>
|
||||
* @since February 2025
|
||||
*/
|
||||
interface BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get all records
|
||||
*
|
||||
* @param array $columns
|
||||
* @return Collection
|
||||
*/
|
||||
public function all(array $columns = ['*']): Collection;
|
||||
|
||||
/**
|
||||
* Get records with pagination
|
||||
*
|
||||
* @param int $perPage
|
||||
* @param array $columns
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function paginate(int $perPage = 15, array $columns = ['*']): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Find a record by ID
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $columns
|
||||
* @return Model|null
|
||||
*/
|
||||
public function find(int $id, array $columns = ['*']): ?Model;
|
||||
|
||||
/**
|
||||
* Find a record by ID or throw an exception
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $columns
|
||||
* @return Model
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
||||
public function findOrFail(int $id, array $columns = ['*']): Model;
|
||||
|
||||
/**
|
||||
* Find records by criteria
|
||||
*
|
||||
* @param array $criteria
|
||||
* @param array $columns
|
||||
* @return Collection
|
||||
*/
|
||||
public function findBy(array $criteria, array $columns = ['*']): Collection;
|
||||
|
||||
/**
|
||||
* Find a single record by criteria
|
||||
*
|
||||
* @param array $criteria
|
||||
* @param array $columns
|
||||
* @return Model|null
|
||||
*/
|
||||
public function findOneBy(array $criteria, array $columns = ['*']): ?Model;
|
||||
|
||||
/**
|
||||
* Create a new record
|
||||
*
|
||||
* @param array $data
|
||||
* @return Model
|
||||
*/
|
||||
public function create(array $data): Model;
|
||||
|
||||
/**
|
||||
* Update an existing record
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
/**
|
||||
* Update or create a record
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $values
|
||||
* @return Model
|
||||
*/
|
||||
public function updateOrCreate(array $attributes, array $values = []): Model;
|
||||
|
||||
/**
|
||||
* Delete a record by ID
|
||||
*
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(int $id): bool;
|
||||
|
||||
/**
|
||||
* Delete records by criteria
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return int Number of deleted records
|
||||
*/
|
||||
public function deleteBy(array $criteria): int;
|
||||
|
||||
/**
|
||||
* Count records
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return int
|
||||
*/
|
||||
public function count(array $criteria = []): int;
|
||||
|
||||
/**
|
||||
* Check if record exists
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(array $criteria): bool;
|
||||
|
||||
/**
|
||||
* Get records with relationships
|
||||
*
|
||||
* @param array $relations
|
||||
* @return BaseRepositoryInterface
|
||||
*/
|
||||
public function with(array $relations): BaseRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Order records
|
||||
*
|
||||
* @param string $column
|
||||
* @param string $direction
|
||||
* @return BaseRepositoryInterface
|
||||
*/
|
||||
public function orderBy(string $column, string $direction = 'asc'): BaseRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Limit records
|
||||
*
|
||||
* @param int $limit
|
||||
* @return BaseRepositoryInterface
|
||||
*/
|
||||
public function limit(int $limit): BaseRepositoryInterface;
|
||||
}
|
||||
206
app/Interfaces/ResumeRepositoryInterface.php
Normal file
206
app/Interfaces/ResumeRepositoryInterface.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
use App\Models\Resume;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Resume Repository Interface
|
||||
*
|
||||
* Defines the contract for resume-specific data operations.
|
||||
* Extends the base repository with resume-specific methods.
|
||||
*
|
||||
* @author David Valera Melendez <david@valera-melendez.de>
|
||||
* @since February 2025
|
||||
*/
|
||||
interface ResumeRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get user's resumes
|
||||
*
|
||||
* @param int $userId
|
||||
* @param array $columns
|
||||
* @return Collection
|
||||
*/
|
||||
public function getUserResumes(int $userId, array $columns = ['*']): Collection;
|
||||
|
||||
/**
|
||||
* Get user's resumes with pagination
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $perPage
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginatedUserResumes(int $userId, int $perPage = 10): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Find resume by public URL
|
||||
*
|
||||
* @param string $publicUrl
|
||||
* @return Resume|null
|
||||
*/
|
||||
public function findByPublicUrl(string $publicUrl): ?Resume;
|
||||
|
||||
/**
|
||||
* Get public resumes
|
||||
*
|
||||
* @param int $limit
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPublicResumes(int $limit = 20): Collection;
|
||||
|
||||
/**
|
||||
* Get resumes by template
|
||||
*
|
||||
* @param string $template
|
||||
* @return Collection
|
||||
*/
|
||||
public function getResumesByTemplate(string $template): Collection;
|
||||
|
||||
/**
|
||||
* Get resumes by status
|
||||
*
|
||||
* @param string $status
|
||||
* @return Collection
|
||||
*/
|
||||
public function getResumesByStatus(string $status): Collection;
|
||||
|
||||
/**
|
||||
* Get popular resumes (most viewed)
|
||||
*
|
||||
* @param int $limit
|
||||
* @param int $days
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPopularResumes(int $limit = 10, int $days = 30): Collection;
|
||||
|
||||
/**
|
||||
* Get recent resumes
|
||||
*
|
||||
* @param int $limit
|
||||
* @param int $days
|
||||
* @return Collection
|
||||
*/
|
||||
public function getRecentResumes(int $limit = 10, int $days = 7): Collection;
|
||||
|
||||
/**
|
||||
* Search resumes
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $filters
|
||||
* @param int $limit
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchResumes(string $query, array $filters = [], int $limit = 20): Collection;
|
||||
|
||||
/**
|
||||
* Get incomplete resumes
|
||||
*
|
||||
* @param int $threshold
|
||||
* @return Collection
|
||||
*/
|
||||
public function getIncompleteResumes(int $threshold = 50): Collection;
|
||||
|
||||
/**
|
||||
* Duplicate resume for user
|
||||
*
|
||||
* @param int $resumeId
|
||||
* @param int $userId
|
||||
* @param string $newTitle
|
||||
* @return Resume
|
||||
*/
|
||||
public function duplicateResume(int $resumeId, int $userId, string $newTitle): Resume;
|
||||
|
||||
/**
|
||||
* Update resume view count
|
||||
*
|
||||
* @param int $resumeId
|
||||
* @return bool
|
||||
*/
|
||||
public function incrementViewCount(int $resumeId): bool;
|
||||
|
||||
/**
|
||||
* Update resume download count
|
||||
*
|
||||
* @param int $resumeId
|
||||
* @return bool
|
||||
*/
|
||||
public function incrementDownloadCount(int $resumeId): bool;
|
||||
|
||||
/**
|
||||
* Get resume statistics
|
||||
*
|
||||
* @param int|null $userId
|
||||
* @return array
|
||||
*/
|
||||
public function getResumeStatistics(?int $userId = null): array;
|
||||
|
||||
/**
|
||||
* Get resumes requiring PDF regeneration
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getResumesNeedingPdfRegeneration(): Collection;
|
||||
|
||||
/**
|
||||
* Archive old resumes
|
||||
*
|
||||
* @param int $days
|
||||
* @return int Number of archived resumes
|
||||
*/
|
||||
public function archiveOldResumes(int $days = 365): int;
|
||||
|
||||
/**
|
||||
* Get user's resume by title
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $title
|
||||
* @return Resume|null
|
||||
*/
|
||||
public function getUserResumeByTitle(int $userId, string $title): ?Resume;
|
||||
|
||||
/**
|
||||
* Check if user can create more resumes
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $limit
|
||||
* @return bool
|
||||
*/
|
||||
public function canUserCreateMoreResumes(int $userId, int $limit = 10): bool;
|
||||
|
||||
/**
|
||||
* Get featured resumes for showcase
|
||||
*
|
||||
* @param int $limit
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFeaturedResumes(int $limit = 6): Collection;
|
||||
|
||||
/**
|
||||
* Update resume completion percentage
|
||||
*
|
||||
* @param int $resumeId
|
||||
* @return bool
|
||||
*/
|
||||
public function updateCompletionPercentage(int $resumeId): bool;
|
||||
|
||||
/**
|
||||
* Get resumes expiring soon
|
||||
*
|
||||
* @param int $days
|
||||
* @return Collection
|
||||
*/
|
||||
public function getResumesExpiringSoon(int $days = 7): Collection;
|
||||
|
||||
/**
|
||||
* Bulk update resume status
|
||||
*
|
||||
* @param array $resumeIds
|
||||
* @param string $status
|
||||
* @return int Number of updated resumes
|
||||
*/
|
||||
public function bulkUpdateStatus(array $resumeIds, string $status): int;
|
||||
}
|
||||
157
app/Interfaces/UserRepositoryInterface.php
Normal file
157
app/Interfaces/UserRepositoryInterface.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* User Repository Interface
|
||||
*
|
||||
* Defines the contract for user-specific data operations.
|
||||
* Extends the base repository with user-specific methods.
|
||||
*
|
||||
* @author David Valera Melendez <david@valera-melendez.de>
|
||||
* @since February 2025
|
||||
*/
|
||||
interface UserRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Find a user by email address
|
||||
*
|
||||
* @param string $email
|
||||
* @return User|null
|
||||
*/
|
||||
public function findByEmail(string $email): ?User;
|
||||
|
||||
/**
|
||||
* Find users by status
|
||||
*
|
||||
* @param string $status
|
||||
* @return Collection
|
||||
*/
|
||||
public function findByStatus(string $status): Collection;
|
||||
|
||||
/**
|
||||
* Get users who haven't logged in recently
|
||||
*
|
||||
* @param int $days
|
||||
* @return Collection
|
||||
*/
|
||||
public function getInactiveUsers(int $days = 30): Collection;
|
||||
|
||||
/**
|
||||
* Get users with completed profiles
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getUsersWithCompletedProfiles(): Collection;
|
||||
|
||||
/**
|
||||
* Get users with incomplete profiles
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getUsersWithIncompleteProfiles(): Collection;
|
||||
|
||||
/**
|
||||
* Get users subscribed to newsletter
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getNewsletterSubscribers(): Collection;
|
||||
|
||||
/**
|
||||
* Search users by name or email
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchUsers(string $query, int $limit = 10): Collection;
|
||||
|
||||
/**
|
||||
* Get user statistics
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserStatistics(): array;
|
||||
|
||||
/**
|
||||
* Update user's last login information
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $ipAddress
|
||||
* @return bool
|
||||
*/
|
||||
public function updateLastLogin(int $userId, string $ipAddress): bool;
|
||||
|
||||
/**
|
||||
* Increment user's login attempts
|
||||
*
|
||||
* @param string $email
|
||||
* @return bool
|
||||
*/
|
||||
public function incrementLoginAttempts(string $email): bool;
|
||||
|
||||
/**
|
||||
* Reset user's login attempts
|
||||
*
|
||||
* @param string $email
|
||||
* @return bool
|
||||
*/
|
||||
public function resetLoginAttempts(string $email): bool;
|
||||
|
||||
/**
|
||||
* Lock user account
|
||||
*
|
||||
* @param string $email
|
||||
* @param int $minutes
|
||||
* @return bool
|
||||
*/
|
||||
public function lockAccount(string $email, int $minutes = 15): bool;
|
||||
|
||||
/**
|
||||
* Check if account is locked
|
||||
*
|
||||
* @param string $email
|
||||
* @return bool
|
||||
*/
|
||||
public function isAccountLocked(string $email): bool;
|
||||
|
||||
/**
|
||||
* Suspend user account
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $reason
|
||||
* @return bool
|
||||
*/
|
||||
public function suspendAccount(int $userId, string $reason): bool;
|
||||
|
||||
/**
|
||||
* Reactivate user account
|
||||
*
|
||||
* @param int $userId
|
||||
* @return bool
|
||||
*/
|
||||
public function reactivateAccount(int $userId): bool;
|
||||
|
||||
/**
|
||||
* Get users registered in date range
|
||||
*
|
||||
* @param string $startDate
|
||||
* @param string $endDate
|
||||
* @return Collection
|
||||
*/
|
||||
public function getUsersRegisteredBetween(string $startDate, string $endDate): Collection;
|
||||
|
||||
/**
|
||||
* Get paginated users with filters
|
||||
*
|
||||
* @param array $filters
|
||||
* @param int $perPage
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginatedUsersWithFilters(array $filters = [], int $perPage = 15): LengthAwarePaginator;
|
||||
}
|
||||
Reference in New Issue
Block a user