user()->id;
$active_packages = Package::where('is_active', 1)
->orderBy('sort_order', 'asc')
->paginate(20);
$active_subscription = PackageSubscription::activeSubscription($user_id);
$upcoming_subscriptions = PackageSubscription::upcomingSubscriptions($user_id);
$waiting_subscriptions = PackageSubscription::waitingSubscriptions($user_id);
return view('user.subscription.index')
->with(compact('active_packages', 'active_subscription', 'upcoming_subscriptions', 'waiting_subscriptions'));
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getAllSubscriptions(Request $request)
{
if ($request->ajax()) {
$package_subscription = PackageSubscription::where('user_id', $request->user()->id)
->select('package_subscriptions.package_details', 'start_date', 'end_date', 'package_price', 'paid_via', 'payment_transaction_id', 'status', 'created_at', 'id as package_subscription_id');
return Datatables::of($package_subscription)
->addColumn('action', '
')
->editColumn('status', '
@lang("messages.".$status)
')
->addColumn('package', function ($row) {
$package_name = ! empty($row->package_details['name']) ? $row->package_details['name'] : '';
return $package_name;
})
->editColumn(
'start_date',
'@php
$date = \Carbon\Carbon::parse($start_date)->isoFormat("D/M/YY");
@endphp
{{$date}}
'
)
->editColumn('end_date', '@php
$date = \Carbon\Carbon::parse($end_date)->isoFormat("D/M/YY");
@endphp
{{$date}}
')
->editColumn('package_price', '
{{$package_price}}
')
->editColumn('created_at', '@php
$date = \Carbon\Carbon::parse($created_at)->isoFormat("D/M/YY");
@endphp
{{$date}}
')
->editColumn('paid_via', '
@if($paid_via == "offline")
@lang("messages.offline")
@else
{{ucfirst($paid_via)}}
@endif
')
->removeColumn('package_subscription_id')
->rawColumns(['action', 'package', 'status', 'start_date', 'end_date', 'paid_via', 'package_price', 'created_at'])
->make(true);
}
return view('user.subscription.index');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
if (request()->ajax()) {
$subscription = PackageSubscription::find($id);
return view('user.subscription.show')
->with(compact('subscription'));
}
}
}