php - Laravel Soft Delete Unique column name -


Suppose I have a table of the class and I have used soft deletion on it. Now for the first time I have added a category "test", after which I have removed this category so that it can update my deleted_at column from the database.

Now that I am trying again, add the category by the name "Test", it is saying that this name has been taken. I have tried those rules that have been posted.

But it is not working. I have used the feature in my model below, my model code is below.

  & lt ;? Php namespace app \ model; Brighten \ Support \ Facades \ Validator as Validator; Use enlightened \ database \ Eloquent \ SoftDeletingTrait; Class category is expanded \ Eloquent {use soft datingset; Protected $ dates = ['deleted_at']; / ** * Protected fields that are full of mass * * @ Sir array * / protected $ protected = array ('id'); / ** * Name of the table used * * @world string * / protected $ table = 'travelcake'; / ** * Validate input * * @ Ultimate array $ input * @ Return Blend (Boolean | Array) * / Valid Public String Function ($ input, $ id = null) {$ rules = array ('name' = & Array ('Required', 'Minimum: 2', 'max: 100', 'regex: / [a-zA-z] /', 'Unique: travel_categories, name, faucet, id, deleted_at, tap' ), 'Description' = & gt; 'Required | Minimum: 2', 'image' = & gt; 'Image'); If ($ id) {$ rule ['name'] = 'is required: Between: 3,64 | Unique: travel_keys, names, '. $ Id; } $ Certification = verifier :: create ($ input, $ rule); Return ($ validation-> pass ()) is true: $ verification-> message (); First of all: I am unable to understand some things. Are you trying to validate for making and updating? Then why can you make the length of construction of the name from 2 to 100, and only 3 to 64 after the update?  

Second: I recommend leaving it:

  protected $ dates = ['deleted_at'];  

I do not see the goal of this.

Third, and I'm talking here, what are you trying to do? I think, what you are trying to do with this filter, which is the name in 'unique: travel_categories, name, null, id, deleted_at, null' To check the uniqueness of the active categories in that situation, that should work.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -