Laravel-Model-Validation
Laravel-Model-Validation copied to clipboard
What if I dont want to save a field but only validate the field?
Ive run into a situation where I would like to validate a field such as Credit Card Expiration and CVV, but I do not want to save the data in the database. At this point Eloquent is complaining that the fields are not in the database and throwing an SQL error. I need the fields to be validated before attempting to charge the credit card. After I am done, I just want to throw away the data.
Is there any way around this? I cannot seem to find a way. Ive also attempted to use various properties such as $guarded and $fillable.
Im sure I will just have to rethink my logic once I find out the answer to this question. Meaning, I will have to validate outside the model validation in this case.
Using Laravel 4.
Thanks.
Ps. nice service BTW.
If I'm understanding your question correclty (english isn't my main language), you could do something like this:
$dog = new Dog(Input::all());
$validate = $dog->validate();
if (!$validate) {
$errors = $dog->getErrors();
}
Was there a fix or workaround for this issue? I'm experiencing it as well.