From ebf4e5243cdff4e162a25ba2f239b5446c638d63 Mon Sep 17 00:00:00 2001 From: cp6 Date: Mon, 25 Sep 2023 23:40:13 +1000 Subject: [PATCH] Added LabelsAssigned::create into try catch Added LabelsAssigned::create into try catch --- app/Models/Labels.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Models/Labels.php b/app/Models/Labels.php index 8a2aa23..8d65968 100644 --- a/app/Models/Labels.php +++ b/app/Models/Labels.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Cache; +use Mockery\Exception; class Labels extends Model { @@ -32,10 +33,14 @@ class Labels extends Model { for ($i = 1; $i <= 4; $i++) { if (!is_null($labels_array[($i - 1)])) { - LabelsAssigned::create([ - 'label_id' => $labels_array[($i - 1)], - 'service_id' => $service_id - ]); + try { + LabelsAssigned::create([ + 'label_id' => $labels_array[($i - 1)], + 'service_id' => $service_id + ]); + } catch (Exception $exception) { + + } } } }