mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 02:10:39 +00:00
frontend & backend update
This commit is contained in:
@@ -3,33 +3,44 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\InvoiceAdminCollection;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Invoice;
|
||||
use App\Services\StripeService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* PlanController constructor.
|
||||
*/
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all invoices
|
||||
*
|
||||
* @return InvoiceCollection
|
||||
* @return InvoiceAdminCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new InvoiceCollection(
|
||||
Invoice::all()
|
||||
return new InvoiceAdminCollection(
|
||||
$this->stripe->getInvoices()['data']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single invoice by $token
|
||||
*
|
||||
* @param $customer
|
||||
* @param $token
|
||||
* @return InvoiceResource
|
||||
*/
|
||||
public function show($token)
|
||||
public function show($customer, $token)
|
||||
{
|
||||
$invoice = Invoice::where('token', $token)->firstOrFail();
|
||||
$invoice = $this->stripe->getUserInvoice($customer, $token);
|
||||
|
||||
return view('vuefilemanager.invoice')
|
||||
->with('invoice', $invoice);
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Plan;
|
||||
use App\Services\StripeService;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Rinvex\Subscriptions\Models\PlanFeature;
|
||||
|
||||
class PlanController extends Controller
|
||||
@@ -30,9 +31,18 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new PlanCollection(
|
||||
$this->stripe->getPlans()
|
||||
);
|
||||
// Store or Get plans to cache
|
||||
if (Cache::has('plans')) {
|
||||
|
||||
$plans = Cache::get('plans');
|
||||
} else {
|
||||
|
||||
$plans = Cache::rememberForever('plans', function () {
|
||||
return $this->stripe->getPlans();
|
||||
});
|
||||
}
|
||||
|
||||
return new PlanCollection($plans);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,9 +53,18 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return new PlanResource(
|
||||
$this->stripe->getPlan($id)
|
||||
);
|
||||
// Store or Get plan to cache
|
||||
if (Cache::has('plan-' . $id)) {
|
||||
|
||||
$plan = Cache::get('plan-' . $id);
|
||||
} else {
|
||||
|
||||
$plan = Cache::rememberForever('plan-' . $id, function () use ($id) {
|
||||
return $this->stripe->getPlan($id);
|
||||
});
|
||||
}
|
||||
|
||||
return new PlanResource($plan);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,9 +75,14 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
return new PlanResource(
|
||||
$plan = new PlanResource(
|
||||
$this->stripe->createPlan($request)
|
||||
);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing']);
|
||||
|
||||
return $plan;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,6 +96,9 @@ class PlanController extends Controller
|
||||
{
|
||||
$this->stripe->updatePlan($request, $id);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing', 'plan-' . $id]);
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
@@ -85,6 +112,9 @@ class PlanController extends Controller
|
||||
{
|
||||
$this->stripe->deletePlan($id);
|
||||
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing']);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Services\StripeService;
|
||||
use App\Share;
|
||||
use App\User;
|
||||
use App\UserSettings;
|
||||
@@ -29,6 +30,11 @@ use Storage;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function __construct(StripeService $stripe)
|
||||
{
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user details
|
||||
*
|
||||
@@ -58,13 +64,14 @@ class UserController extends Controller
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @param $id
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function invoices($id)
|
||||
public function invoices()
|
||||
{
|
||||
$user = \Auth::user();
|
||||
|
||||
return new InvoiceCollection(
|
||||
User::findOrFail($id)->invoices
|
||||
$this->stripe->getUserInvoices($user)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +84,7 @@ class UserController extends Controller
|
||||
public function subscription($id)
|
||||
{
|
||||
return new UserSubscription(
|
||||
User::findOrFail($id)->subscription('main')
|
||||
User::find($id)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user