<?php

namespace App\Services\APIs\CustomerAPIs;

use App\Models\ManageReferralRule;
use App\Models\ManageRule;
use Illuminate\Support\Facades\Log;

use Exception;

class RulesApiServices
{
    public function getVoucherRules()
    {
        try {
            $data = ManageRule::select('id', 'whats_inside', 'rules')
                ->get()
                ->toArray();

            return $data;
        } catch (Exception $ex) {
            Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage());
            return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
        }
    }


    public function getReferralRules()
    {
        try {
            $data = ManageReferralRule::select('id', 'how_it_works', 'rules','what_is_referral')
                ->get()
                ->toArray();

            return $data;
        } catch (Exception $ex) {
            Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage());
            return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
        }
    }
}
