first init
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace $CLASS_NAMESPACE$;
|
||||
|
||||
use Modules\$MODULE$\Entities\$MODULE$;
|
||||
use Modules\$MODULE$\Repositories\Contracts\$MODULE$RepositoryInterface;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class $CLASS$ implements $MODULE$RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get all $LOWER_NAME$s with pagination and search
|
||||
*/
|
||||
public function getAllPaginated(int $perPage = 10, string $search = '')
|
||||
{
|
||||
$query = $MODULE$::orderBy('name');
|
||||
|
||||
if (!empty($search)) {
|
||||
$query->where('name', 'LIKE', "%{$search}%");
|
||||
}
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all $LOWER_NAME$s with their relationships and pagination with search
|
||||
*/
|
||||
public function getAllWithRelationsPaginated(int $perPage = 10, string $search = '')
|
||||
{
|
||||
$query = $MODULE$::orderBy('name');
|
||||
|
||||
if (!empty($search)) {
|
||||
$query->where('name', 'LIKE', "%{$search}%");
|
||||
}
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all $LOWER_NAME$s with their relationships and search
|
||||
*/
|
||||
public function getAllWithRelations(string $search = ''): Collection
|
||||
{
|
||||
$query = $MODULE$::orderBy('name');
|
||||
|
||||
if (!empty($search)) {
|
||||
$query->where('name', 'LIKE', "%{$search}%");
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new $LOWER_NAME$
|
||||
*/
|
||||
public function create(array $data): $MODULE$
|
||||
{
|
||||
return $MODULE$::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find $LOWER_NAME$ by ID
|
||||
*/
|
||||
public function findById(int $id): ?$MODULE$
|
||||
{
|
||||
return $MODULE$::find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete $LOWER_NAME$ (soft delete)
|
||||
*/
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$$LOWER_NAME$ = $MODULE$::find($id);
|
||||
if ($$LOWER_NAME$) {
|
||||
return $$LOWER_NAME$->delete();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all $LOWER_NAME$s
|
||||
*/
|
||||
public function all(string $search = ''): Collection
|
||||
{
|
||||
$query = $MODULE$::orderBy('name');
|
||||
|
||||
if (!empty($search)) {
|
||||
$query->where('name', 'LIKE', "%{$search}%");
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user