-
app/View/Classes/DiscountExpiry.php
Open in GitHubuse App\Traits\DiscountExpiry as TraitsDiscountExpiry; class DiscountExpiry { use TraitsDiscountExpiry; }
-
app/Traits/DiscountExpiry.php
Open in GitHubuse App\Models\Discount; use Carbon\Carbon; trait DiscountExpiry { public function checkDiscount($id) { $discount = Discount::find($id); if ($discount) { if (Carbon::parse($discount->end_date)->timestamp > Carbon::now()->timestamp || is_null($discount->end_date)) { return $discount; } } return false; } // }
-
app/Http/Controllers/Store/OrderController.php
Open in GitHubuse App\Traits\DiscountExpiry; use Illuminate\Http\Request; class OrderController extends Controller { use DiscountExpiry; public function show($id) { $plan = Plan::find($id); $discount = $this->checkDiscount($plan->discount); // } }