- Created api.php for handling authentication routes (register, login, logout) with token middleware. - Implemented task management routes using API resource controller. feat: add console routes for artisan commands - Added console.php to define an inspiring quote command. feat: add web routes for homepage - Created web.php to serve the welcome view at the root URL. chore: add .gitignore files for storage directories - Added .gitignore files in storage/app, storage/framework, and storage/logs to exclude unnecessary files from version control. test: add feature and unit tests - Created ExampleTest in Feature and Unit directories to verify basic application responses and assertions. build: add Vite configuration for Laravel and Tailwind CSS - Added vite.config.js to configure Vite with Laravel and Tailwind CSS for asset management.
46 lines
953 B
PHP
46 lines
953 B
PHP
<?php
|
|
|
|
namespace App\Http\Repositories;
|
|
|
|
use App\Interfaces\TaskRepositoryInterface;
|
|
use App\Models\Task;
|
|
|
|
class TaskRepository implements TaskRepositoryInterface
|
|
{
|
|
public function getTasks(array $filters)
|
|
{
|
|
$query = Task::query();
|
|
|
|
// filter berdasarkan user
|
|
if (isset($filters['user_id'])) {
|
|
$query->where('user_id', $filters['user_id']);
|
|
}
|
|
|
|
// filter berdasarkan status is_done
|
|
if (isset($filters['is_done'])) {
|
|
$query->where('is_done', $filters['is_done']);
|
|
}
|
|
|
|
// pagination
|
|
$perPage = $filters['per_page'] ?? 10;
|
|
|
|
return $query->paginate($perPage);
|
|
}
|
|
|
|
public function store(array $data)
|
|
{
|
|
return Task::create($data);
|
|
}
|
|
|
|
public function update($task, array $data)
|
|
{
|
|
$task->update($data);
|
|
return $task;
|
|
}
|
|
|
|
public function delete($task)
|
|
{
|
|
return $task->delete();
|
|
}
|
|
}
|