Skip to content

Commit

Permalink
add backup & sitemap features
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jul 29, 2021
1 parent cd08b8c commit fb8feec
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
11 changes: 9 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 13 additions & 21 deletions app/Http/Controllers/Admin/HelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ public function settings(Request $request){
}

public function backups(){
$getBackups = File::allFiles(storage_path('app/Laravel'));
$exists = File::exists(storage_path('app/Laravel'));
if($exists){
$getBackups = File::allFiles(storage_path('app/Laravel'));
}
else {
$getBackups = [];
}

return view('admin.setting.backups', [
'backups' => $getBackups
]);

}

public function saveBackups(Request $request){
Expand All @@ -51,34 +59,18 @@ public function saveBackups(Request $request){
if($getFile){
return response()->file($request->get('path'));
}

}
else {
exec('cd ' . base_path() . ' && /opt/homebrew/Cellar/[email protected]/7.4.15/bin/php artisan backup:run', $output, $code);
Artisan::call('backup:run');
toast(__('Backup Run!'),'success');
return back();
}
}

public function sitemap(){
return view('admin.setting.sitemap');
}

public function saveSitemap(Request $request){

setting_update('site.name', $request->get('site_name'));
setting_update('site.description', $request->get('site_description'));
setting_update('site.keywords', $request->get('site_keywords'));
setting_update('site.author', $request->get('site_author'));
$file = $request->file('site_logo');
if($file){
$imageName = time().'.'.$request->site_logo->extension();
$request->site_logo->move(public_path('images/settings'), $imageName);
setting_update('site.logo', '/images/settings/'. $imageName);
}

toast(__('SEO Updates!'),'success');
return back();
Artisan::call('sitemap:generate');
toast(__('Sitemap Has Been Generated!'),'success');
return redirect()->to('admin/settings');
}

public function modules(){
Expand Down
6 changes: 0 additions & 6 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>http://lamba.test/</loc>
<lastmod>2021-03-13T11:45:25+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
1 change: 1 addition & 0 deletions resources/views/admin/layout/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<li class="nav-item"><a class="nav-link" href="{{ url('admin/payment') }}"><i class="nav-icon icon-credit-card"></i> {{ __('Payments') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('admin/email') }}"><i class="nav-icon icon-envelope-letter"></i> {{ __('Email') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('admin/services') }}"><i class="nav-icon icon-share"></i> {{ __('Services') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url('admin/backups') }}"><i class="nav-icon icon-cloud-download"></i> {{ __('Backups') }}</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="{{ url('admin/settings') }}"><i class="nav-icon icon-settings"></i> {{ __('Settings') }}</a></li>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/setting/backups.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="card">
<div class="card-header">
<i class="icon icon-cloud-download"></i>
{{__('Backups')}}
{{__('Backups')}} <span class="badge badge-danger"><i class="fa fa-info"></i> {{__('Under Development')}}</span>

<div class="pull-right">
<form method="POST" action="{{url('admin/backups')}}">
Expand Down
1 change: 1 addition & 0 deletions resources/views/admin/setting/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{!! setting_show('site.description', __('Site Description'), 'textarea') !!}
{!! setting_show('site.keywords', __('Site Keywords'), 'textarea') !!}
<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> {{__('Save')}}</button>
<a href="{{url('admin/settings/sitemap')}}" class="btn btn-success"><i class="fa fa-sitemap"></i> {{__('Generate Sitemap')}}</a>
</form>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
Route::get('/themes', 'HelperController@themes')->name('themes');
Route::post('/themes', 'HelperController@saveThemes')->name('save-themes');
Route::get('/themes/active', 'HelperController@themeActive')->name('theme-active');
Route::get('/settings/sitemap', 'HelperController@sitemap')->name('sitemap');
Route::get('/backups', 'HelperController@backups')->name('backups');
Route::post('/backups', 'HelperController@saveBackups')->name('saveBackups');
});
});

Expand Down

0 comments on commit fb8feec

Please sign in to comment.