fix last code for this part
This commit is contained in:
@@ -54,7 +54,11 @@ class PanjareVahedController extends Controller
|
||||
|
||||
$state = HarimStates::BARESI_EDARE_SHAHRESTAN->value;
|
||||
|
||||
$harim = Harim::query()->create([
|
||||
$harim = Harim::query()->firstOrCreate(
|
||||
[
|
||||
'panjare_vahed_id' => $request->request_id
|
||||
],
|
||||
[
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'panjare_vahed_id' => $request->request_id,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\PanjareVahed;
|
||||
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
@@ -46,21 +47,11 @@ class ReceiveNewRequest extends FormRequest
|
||||
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
if ($validator->errors()->has('request_id') && str_contains($validator->errors()->first('request_id'), 'unique'))
|
||||
{
|
||||
$response = response()->json([
|
||||
'statusCode' => 201,
|
||||
'message' => 'already stored',
|
||||
], 201);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = response()->json([
|
||||
'statusCode' => 422,
|
||||
'message' => 'invalid inputs',
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
}
|
||||
$response = response()->json([
|
||||
'statusCode' => 422,
|
||||
'message' => 'invalid inputs',
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user