|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/.trash/app.bak.10/Validation/ |
Upload File : |
<?php
namespace App\Validation;
use CodeIgniter\Config\Services;
class CustomRules
{
public function store_is_unique(string $str, string $fields, array $data)
{
$session = Services::session();
$arr = explode(',', $fields);
$column_name = $arr[0];
$baseModel = $arr[1];
$pathModel = '\App\Models\\' . $baseModel;
$model = new $pathModel();
$result = $model->where('ps_store_id', $session->get('ps_store_id'))->where($column_name, $str)->first();
if (empty($result)) {
return true;
} else {
return false;
}
}
public function username_is_unique(string $str, string $fields, array $data)
{
$session = Services::session();
$arr = explode(',', $fields);
$column_name = $arr[0];
$baseModel = $arr[1];
$pathModel = '\App\Models\\' . $baseModel;
$model = new $pathModel();
$result = $model->where($column_name, $str)->first();
if (empty($result)) {
return true;
} else {
return false;
}
}
}