added blade cache system to Page Speed Optimization

added clear cache to settings
pull/49/head v2.1.1
A1Gard 2 months ago
parent bf4422530b
commit c4f5662c12

@ -1418,3 +1418,9 @@ function findArea($name,$model = null)
} }
return \App\Models\Area::where('name', $name)->first(); return \App\Models\Area::where('name', $name)->first();
} }
function cacheNumber()
{
return getSetting('cache_number');
}

@ -9,6 +9,7 @@ use App\Models\Group;
use App\Models\Menu; use App\Models\Menu;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
class SettingController extends Controller class SettingController extends Controller
{ {
@ -18,7 +19,7 @@ class SettingController extends Controller
public function index() public function index()
{ {
// //
$settings = Setting::where('active', 1) $settings = Setting::where('active', true)
->orderBy('section')->get(); //ESH// just active setting`s show ->orderBy('section')->get(); //ESH// just active setting`s show
$cats = Category::all(['id','name']); $cats = Category::all(['id','name']);
$menus = Menu::all(['id','name']); $menus = Menu::all(['id','name']);
@ -108,4 +109,15 @@ class SettingController extends Controller
{ {
// //
} }
public function cacheClear(){
$f = Setting::where('key','cache_number')->first();
$f->value += 1;
$f->save();
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('view:clear');
Artisan::call('route:clear');
return redirect()->back()->with(['message' => __('Cache cleared')]);
}
} }

@ -21,6 +21,7 @@
"laravel/ui": "^4.5", "laravel/ui": "^4.5",
"pishran/zarinpal": "^4.3", "pishran/zarinpal": "^4.3",
"plank/laravel-metable": "^6.0", "plank/laravel-metable": "^6.0",
"ryangjchandler/blade-cache-directive": "^1.0",
"spatie/laravel-medialibrary": "^11.4", "spatie/laravel-medialibrary": "^11.4",
"spatie/laravel-permission": "^6.7", "spatie/laravel-permission": "^6.7",
"spatie/laravel-tags": "^4.6", "spatie/laravel-tags": "^4.6",

76
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "09d427100f16e5c56fab40748b855feb", "content-hash": "ef8964addedfac8764b7d88ec133cf16",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@ -4413,6 +4413,80 @@
}, },
"time": "2024-07-08T08:10:42+00:00" "time": "2024-07-08T08:10:42+00:00"
}, },
{
"name": "ryangjchandler/blade-cache-directive",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/ryangjchandler/blade-cache-directive.git",
"reference": "00b950f3e14a06d58528293e237d58795abe7df3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ryangjchandler/blade-cache-directive/zipball/00b950f3e14a06d58528293e237d58795abe7df3",
"reference": "00b950f3e14a06d58528293e237d58795abe7df3",
"shasum": ""
},
"require": {
"illuminate/contracts": "^11.0",
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"brianium/paratest": "^7.4",
"nunomaduro/collision": "^8.0",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ray": "^1.9",
"vimeo/psalm": "^4.4|^5.22"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"RyanChandler\\BladeCacheDirective\\BladeCacheDirectiveServiceProvider"
],
"aliases": {
"BladeCacheDirective": "RyanChandler\\BladeCacheDirective\\BladeCacheDirectiveFacade"
}
}
},
"autoload": {
"psr-4": {
"RyanChandler\\BladeCacheDirective\\": "src",
"RyanChandler\\BladeCacheDirective\\Database\\Factories\\": "database/factories"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ryan Chandler",
"email": "support@ryangjchandler.co.uk",
"role": "Developer"
}
],
"description": "Cache chunks of your Blade markup with ease.",
"homepage": "https://github.com/ryangjchandler/blade-cache-directive",
"keywords": [
"blade-cache-directive",
"laravel",
"ryangjchandler"
],
"support": {
"issues": "https://github.com/ryangjchandler/blade-cache-directive/issues",
"source": "https://github.com/ryangjchandler/blade-cache-directive/tree/v1.0.0"
},
"funding": [
{
"url": "https://github.com/ryangjchandler",
"type": "github"
}
],
"time": "2024-03-13T00:05:30+00:00"
},
{ {
"name": "setasign/fpdi", "name": "setasign/fpdi",
"version": "v2.6.1", "version": "v2.6.1",

@ -0,0 +1,9 @@
<?php
return [
'enabled' => env('BLADE_CACHE_DIRECTIVE_ENABLED', true),
'ttl' => env('BLADE_CACHE_DIRECTIVE_TTL', 3600),
];

@ -93,6 +93,13 @@ class SettingSeeder extends Seeder
'type' => 'CHECKBOX', 'type' => 'CHECKBOX',
'value' => 0, 'value' => 0,
], ],
[
'title' => __('Cache'),
'key' => 'cache_number',
'type' => 'TEXT',
'value' => 0,
'active' => false,
],
], ],
'SMS' => [ 'SMS' => [
@ -223,6 +230,7 @@ class SettingSeeder extends Seeder
$setting->value = $set['value'] ?? null; $setting->value = $set['value'] ?? null;
$setting->type = $set['type'] ?? 'TEXT'; $setting->type = $set['type'] ?? 'TEXT';
$setting->ltr = $set['ltr'] ?? false; $setting->ltr = $set['ltr'] ?? false;
$setting->active = $set['active'] ?? true;
$setting->is_basic = true; $setting->is_basic = true;
$setting->size = $set['size'] ?? 12;; $setting->size = $set['size'] ?? 12;;
$setting->save(); $setting->save();

@ -19,6 +19,12 @@
{{__("Recommends")}} {{__("Recommends")}}
</li> </li>
</ul> </ul>
<div class="p-2">
<a href="{{ route('admin.setting.cache-clear') }}" class="btn btn-secondary d-block">
{{__("Clear caches")}}
</a>
</div>
</div> </div>
<div class="item-list mb-3"> <div class="item-list mb-3">

@ -10,9 +10,11 @@
<div> <div>
<div id="panel"> <div id="panel">
@cache('navbar_panel'. cacheNumber())
<aside> <aside>
@include('components.panel-side-navbar') @include('components.panel-side-navbar')
</aside> </aside>
@endcache
<div id="sidebar-panel"></div> <div id="sidebar-panel"></div>
<main class="py-3 px-3"> <main class="py-3 px-3">
@include('components.panel-breadcrumb') @include('components.panel-breadcrumb')

@ -1,3 +1,4 @@
@cache('follow_us'. cacheNumber(), 90)
<section id='FollowUsSocial'> <section id='FollowUsSocial'>
<span> <span>
{{__("Follow us")}} {{__("Follow us")}}
@ -8,3 +9,4 @@
</a> </a>
@endforeach @endforeach
</section> </section>
@endcache

@ -1,3 +1,5 @@
@cache('go_top'. cacheNumber())
<a id='SimpleGoTop' href="#"> <a id='SimpleGoTop' href="#">
<i class="{{getSetting($data->area_name.'_'.$data->part.'_icon')}}"></i> <i class="{{getSetting($data->area_name.'_'.$data->part.'_icon')}}"></i>
</a> </a>
@endcache

@ -1,3 +1,4 @@
@cache('wave_footer'. cacheNumber(), 90)
<footer class='FireFooter'> <footer class='FireFooter'>
<div class="footer"> <div class="footer">
<div class="bubbles"> <div class="bubbles">
@ -315,3 +316,4 @@
</defs> </defs>
</svg> </svg>
</footer> </footer>
@endcache

@ -1,3 +1,4 @@
@cache('parallax_footer'. cacheNumber(), 90)
<footer class='ParallaxFooter' style="background-image: url('{{asset('upload/images/'.$data->area_name.'.'.$data->part.'.jpg')}}')"> <footer class='ParallaxFooter' style="background-image: url('{{asset('upload/images/'.$data->area_name.'.'.$data->part.'.jpg')}}')">
<div class="{{gfx()['container']}}"> <div class="{{gfx()['container']}}">
<div class="row"> <div class="row">
@ -44,3 +45,4 @@
{{getSetting('copyright')}} {{getSetting('copyright')}}
</p> </p>
</footer> </footer>
@endcache

@ -1,3 +1,4 @@
@cache('simple_footer'. cacheNumber(), 90)
<section class='SimpleFooter'> <section class='SimpleFooter'>
<div class="content"> <div class="content">
<div class="{{gfx()['container']}}"> <div class="{{gfx()['container']}}">
@ -52,3 +53,4 @@
</p> </p>
</div> </div>
</section> </section>
@endcache

@ -1,4 +1,4 @@
@cache('wave_footer'. cacheNumber(), 90)
<footer class='WaveFooter' <footer class='WaveFooter'
style="--speed: {{getSetting($data->area_name.'_'.$data->part.'_speed')}}s; style="--speed: {{getSetting($data->area_name.'_'.$data->part.'_speed')}}s;
--speed2: {{getSetting($data->area_name.'_'.$data->part.'_speed2')}}s; --speed2: {{getSetting($data->area_name.'_'.$data->part.'_speed2')}}s;
@ -46,3 +46,4 @@
{{getSetting('copyright')}} </div> {{getSetting('copyright')}} </div>
</div> </div>
</footer> </footer>
@endcache

@ -1,3 +1,4 @@
@cache('post_sidebar_2'. cacheNumber(), 90)
<aside class="p-4"> <aside class="p-4">
<h4> <h4>
{{__("Search")}} {{__("Search")}}
@ -42,3 +43,4 @@
@endforeach @endforeach
</ul> </ul>
</aside> </aside>
@endcache

@ -1,3 +1,4 @@
@cache('post_sidebar1'. cacheNumber(), 90)
<aside class="p-4"> <aside class="p-4">
<h4> <h4>
{{__("Search")}} {{__("Search")}}
@ -42,3 +43,4 @@
@endforeach @endforeach
</ul> </ul>
</aside> </aside>
@endcache

@ -1,4 +1,5 @@
<aside class="mt-2"> <aside class="mt-2">
@cache('product_sidebar'. cacheNumber(), 90)
<div class="side-item"> <div class="side-item">
<h4> <h4>
{{__("Search")}} {{__("Search")}}
@ -22,6 +23,7 @@
</ul> </ul>
</div> </div>
</div> </div>
@endcache
<div class="side-item"> <div class="side-item">
<h4> <h4>
{{__("Filter")}} {{__("Filter")}}

@ -340,6 +340,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('index', [\App\Http\Controllers\Admin\SettingController::class, "index"])->name('index'); Route::get('index', [\App\Http\Controllers\Admin\SettingController::class, "index"])->name('index');
Route::post('store', [\App\Http\Controllers\Admin\SettingController::class, "store"])->name('store'); Route::post('store', [\App\Http\Controllers\Admin\SettingController::class, "store"])->name('store');
Route::post('update', [\App\Http\Controllers\Admin\SettingController::class, "update"])->name('update'); Route::post('update', [\App\Http\Controllers\Admin\SettingController::class, "update"])->name('update');
Route::get('cache/clear', [\App\Http\Controllers\Admin\SettingController::class, "cacheClear"])->name('cache-clear');
} }
); );
Route::prefix('gfx')->name('gfx.')->group( Route::prefix('gfx')->name('gfx.')->group(

Loading…
Cancel
Save