47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Services\APIs\CustomerAPIs;
|
|
|
|
use App\Models\ManageFeedback;
|
|
use App\Models\IamPrincipal;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Exception;
|
|
use Carbon\Carbon;
|
|
|
|
|
|
class FeedbackApiServices
|
|
{
|
|
|
|
public function storeFeedback($customerIamId, $request)
|
|
{
|
|
try {
|
|
DB::beginTransaction();
|
|
$user_data = IamPrincipal::where('id', $customerIamId)->first();
|
|
$now = Carbon::now();
|
|
$reaction = $request->input('reaction');
|
|
$comment = $request->input('comment');
|
|
|
|
$feedbackData = [
|
|
'principal_xid' => $user_data->id,
|
|
'feedback_reaction_xid' => $reaction,
|
|
'comment' => $comment,
|
|
'is_app_feedback' => $request->is_app_feedback,
|
|
'is_restaurant_feedback' => $request->is_restaurant_feedback,
|
|
'restaurant_id' => $request->restaurant_id,
|
|
];
|
|
|
|
$feedback = ManageFeedback::create($feedbackData);
|
|
|
|
DB::commit();
|
|
return jsonResponseWithSuccessMessageApi(__('auth.feedback_store'), [], 200);
|
|
} catch (Exception $ex) {
|
|
DB::rollBack();
|
|
Log::error('Update Quantity service failed: ' . $ex->getMessage());
|
|
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
|
}
|
|
}
|
|
}
|