initial project

This commit is contained in:
2025-11-06 13:41:06 +08:00
commit 1b08727cb2
209 changed files with 31602 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?
namespace App\Services;
use App\Models\CustomerVoucherList;
class VoucherService
{
private $customer_voucher_list;
public function __construct()
{
$this->customer_voucher_list = new CustomerVoucherList();
}
public function checkVoucherAvailability($customer_voucher_list_id, $order_type, $customer_id)
{
$customer_voucher = $this->customer_voucher_list->where('id', $customer_voucher_list_id)->where('customer_id', $customer_id)->first();
if(empty($customer_voucher)){
return ['status' => 400, 'result' => 'Customer voucher not found.'];
}
$current_date = date('Y-m-d');
if($current_date > $customer_voucher['voucher_expiry_date']){
return ['status' => 400, 'result' => 'Voucher already expired.'];
}
if($customer_voucher['voucher_status'] != 'active'){
return ['status' => 400, 'result' => 'Voucher already ' . $customer_voucher['voucher_status'] . '.'];
}
}
}
?>