mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
- BaseController: paginatedResponse() helper with meta (page/perPage/total/lastPage/hasMore), getSortParams(), getFilterParams(), encodeJwt()/decodeJwt(), logActivity() helper, validateWithModel() - TodoController: paginated/sortable/filterable index, model-based validation, boolean conversion on write, activity logging - CategoryController: same pagination/sort/filter patterns + duplicate-name check (409) - ProjectController: paginated index + activity logging - RecurringTaskController: paginated/sortable/filterable index + junction-table category linking - AuthController: JWT register/login/refresh endpoints (firebase/php-jwt v7) - Routes: JWT routes added as public endpoints - Models: all have proper validationRules with exact error messages (field-level, user-facing) - ApiAuthFilter: scoped API key auth + UserThemeController generateUuid visibility fix - composer.json: add firebase/php-jwt ^7.0
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class UserModel extends Model
|
|
{
|
|
protected $table = 'users';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = false;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = false;
|
|
protected $allowedFields = [
|
|
'id', 'email', 'password_hash', 'name', 'avatar_url',
|
|
'settings', 'created_at', 'updated_at',
|
|
];
|
|
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'created_at';
|
|
protected $updatedField = 'updated_at';
|
|
|
|
protected $validationRules = [
|
|
'email' => [
|
|
'rules' => 'required|valid_email|is_unique[users.email]',
|
|
'errors' => [
|
|
'required' => 'Email is required.',
|
|
'valid_email' => 'Please provide a valid email address.',
|
|
'is_unique' => 'This email is already registered.',
|
|
],
|
|
],
|
|
'name' => [
|
|
'rules' => 'required|max_length[255]',
|
|
'errors' => [
|
|
'required' => 'Name is required.',
|
|
'max_length' => 'Name must not exceed 255 characters.',
|
|
],
|
|
],
|
|
];
|
|
}
|