phpvms/app/Http/Controllers/Admin/MaintenanceController.php
Nabeel S b213f2bb4c
Add maintenance section to admin, clear caches #376 (#377)
* Add maintenance section to admin, clear caches #376

* Formatting
2019-08-30 15:59:08 -04:00

53 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Contracts\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Laracasts\Flash\Flash;
class MaintenanceController extends Controller
{
public function __construct()
{
}
public function index()
{
return view('admin.maintenance.index');
}
/**
* Clear caches depending on the type passed in
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function cache(Request $request)
{
$calls = [];
$type = $request->get('type');
// When clearing the application, clear the config and the app itself
if ($type === 'application' || $type === 'all') {
$calls[] = 'config:cache';
$calls[] = 'cache:clear';
$calls[] = 'route:cache';
}
// If we want to clear only the views but keep everything else
if ($type === 'views' || $type === 'all') {
$calls[] = 'view:clear';
}
foreach ($calls as $call) {
Artisan::call($call);
}
Flash::success('Cache cleared!');
return redirect(route('admin.maintenance.index'));
}
}