I have the store method of a Size class, which uses the NewSizesRequest validator
public function store(NewSizesRequest $r) {
if ($r->ajax()) {
$this->sizesInterface->store($r->all());
return response()->json("Mensaje");
}
}
In the NewSizeRequest class I have the following rule:
public function rules() {
return [
'size' => 'required|numeric|unique:sizes,size'
];
}
The problem is in the following case:
I add an 'x' size to the database. Then I delete that record with SoftDelete. Now if I put to add a size again and repeat 'x' it tells me that it already exists even if it is not shown by the deleted_at.
I can not find a way to do that if it exists, make a $ size-> restore (), as if I had created it, but restore it just now!