feat: add API routes for authentication and task management
- 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.
This commit is contained in:
42
app/Http/Requests/AuthRequest.php
Normal file
42
app/Http/Requests/AuthRequest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AuthRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users',
|
||||
'password' => 'required|min:8'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Username wajib diisi!',
|
||||
'email.required' => 'Email wajib diisi!',
|
||||
'email.email' => 'Format Email tidak valid!',
|
||||
'email.unique' => 'Email sudah terdaftar!',
|
||||
'password.required' => 'Password wajib diisi!',
|
||||
'password.min' => 'Password minimal 8 karakter!'
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/TaskRequest.php
Normal file
39
app/Http/Requests/TaskRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class TaskRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
];
|
||||
|
||||
// jika update, title tidak wajib diisi
|
||||
if ($this->isMethod('put') || $this->isMethod('patch')) {
|
||||
$rules['title'] = 'sometimes|string|max:255';
|
||||
$rules['is_done'] = 'sometimes|boolean';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'Judul task wajib diisi!',
|
||||
'title.string' => 'Judul task harus berupa teks!',
|
||||
'title.max' => 'Judul task maksimal 255 karakter!',
|
||||
'is_done.boolean' => 'Status task harus bernilai 0 atau 1!',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user