mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
added migration seeders models and test script
This commit is contained in:
48
app/Models/UserModel.php
Normal file
48
app/Models/UserModel.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class UserModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
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' => 'required|valid_email|is_unique[users.email]',
|
||||
'password_hash' => 'required',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'email' => [
|
||||
'required' => 'Email is required',
|
||||
'valid_email' => 'Please enter a valid email address',
|
||||
'is_unique' => 'This email is already registered',
|
||||
],
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'user';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user