Welcome Guest, Not a member yet? Register   Sign In
Custom validation
#1

hi i have a problem to validate is_unique with soft delete , i create a custom rule :
Code:
    /**
  * Funzione che controlla se è presente la macchina in magazzino
  */
    public function macchina_presente_is_unique(string $str,string $fields, array $data)
    {
        $macchina_model = new MacchinaModel();

        $macchina = $macchina_model->where('seriale',$data['seriale'])->first();

        if ($macchina) {

            return false;
        }else{

            return true;
        }

    }
There is a way to add a field to ignore id as is_unique {id}
Reply
#2

PHP Code:
->withDeleted()->first(); 
Reply
#3

(This post was last modified: 05-09-2023, 12:04 PM by pippuccio76.)

(05-08-2023, 04:53 PM)Mni.day Wrote:
PHP Code:
->withDeleted()->first(); 

No in this way Is the same as is_unique ... 

I want add a value tò control the id , i create another function , i want know of Is It possible do with only one function
Reply




Theme © iAndrew 2016 - Forum software by © MyBB