* Add maintenance section to admin, clear caches #376 * Formatting
This commit is contained in:
@@ -39,3 +39,6 @@
|
||||
- name: settings
|
||||
display_name: Settings
|
||||
description: Edit VA settings
|
||||
- name: maintenance
|
||||
display_name: Maintenance
|
||||
description: Run maintenance tasks
|
||||
|
||||
52
app/Http/Controllers/Admin/MaintenanceController.php
Normal file
52
app/Http/Controllers/Admin/MaintenanceController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,10 @@ Route::group([
|
||||
Route::match(['get'], 'settings', 'SettingsController@index');
|
||||
Route::match(['post', 'put'], 'settings', 'SettingsController@update')->name('settings.update');
|
||||
|
||||
// maintenance
|
||||
Route::match(['get'], 'maintenance', 'MaintenanceController@index')->name('maintenance.index');
|
||||
Route::match(['post'], 'maintenance', 'MaintenanceController@cache')->name('maintenance.cache');
|
||||
|
||||
// subfleet
|
||||
Route::get('subfleets/export', 'SubfleetController@export')->name('subfleets.export');
|
||||
Route::match(['get', 'post'], 'subfleets/import', 'SubfleetController@import')->name('subfleets.import');
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
29
resources/views/admin/maintenance/caches.blade.php
Normal file
29
resources/views/admin/maintenance/caches.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="form-container">
|
||||
<h6><i class="fas fa-clock"></i>
|
||||
Reset Caches
|
||||
</h6>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 text-center">
|
||||
{{ Form::open(['route' => 'admin.maintenance.cache']) }}
|
||||
{{ Form::hidden('type', 'all') }}
|
||||
{{ Form::button('Clear all caches', ['type' => 'submit', 'class' => 'btn btn-success']) }}
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
<div class="col-sm-4 text-center">
|
||||
{{ Form::open(['route' => 'admin.maintenance.cache']) }}
|
||||
{{ Form::hidden('type', 'application') }}
|
||||
{{ Form::button('Application', ['type' => 'submit', 'class' => 'btn btn-success']) }}
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
<div class="col-sm-4 text-center">
|
||||
{{ Form::open(['route' => 'admin.maintenance.cache']) }}
|
||||
{{ Form::hidden('type', 'views') }}
|
||||
{{ Form::button('Views', ['type' => 'submit', 'class' => 'btn btn-success']) }}
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
12
resources/views/admin/maintenance/index.blade.php
Normal file
12
resources/views/admin/maintenance/index.blade.php
Normal file
@@ -0,0 +1,12 @@
|
||||
@extends('admin.app')
|
||||
|
||||
@section('title', 'Maintenance')
|
||||
@section('content')
|
||||
@include('flash::message')
|
||||
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
@include('admin.maintenance.caches')
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -74,6 +74,10 @@
|
||||
@ability('admin', 'settings')
|
||||
<li><a href="{{ url('/admin/settings') }}"><i class="pe-7s-config"></i>settings</a></li>
|
||||
@endability
|
||||
|
||||
@ability('admin', 'maintenance')
|
||||
<li><a href="{{ url('/admin/maintenance') }}"><i class="pe-7s-config"></i>maintenance</a></li>
|
||||
@endability
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user