public function getCurrentDiscountAttribute() { $customer_discount = CustomerDiscount::where('customer_id', $this->membership_id)->join('discounts', 'discounts.id', '=', 'discounts_customers.discount_id')->get(); if (count($customer_discount) > 0) { foreach ($customer_discount as $c) { $dt = Carbon::parse($c->expiration); if ($c->expiration->diffInDays() > 0) { return $c; } } } //return $customer_discount; }
public function deleteCustomerDiscounts($id) { $cd = CustomerDiscount::where('id', $id)->first(); if ($cd) { $cd->delete(); return 'success'; } }