firstcommit
This commit is contained in:
199
app/Providers/AppServiceProvider.php
Normal file
199
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Modules\Blog\app\Models\Blog;
|
||||
use Modules\Page\app\Models\Page;
|
||||
use Modules\Post\app\Models\Post;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Service\app\Models\Service;
|
||||
use Modules\Setting\app\Models\Setting;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
$this->getSeoSetting();
|
||||
$this->getGeneralSetting();
|
||||
$this->getAdditionalSetting();
|
||||
|
||||
//-- Social media
|
||||
$this->socialMediaShare();
|
||||
|
||||
//-- Social media
|
||||
|
||||
//-- Blog
|
||||
$this->blog();
|
||||
|
||||
//-- Site Logo
|
||||
$this->getSiteImage();
|
||||
$this->getMultipleSiteImage();
|
||||
|
||||
$this->getHairPosts();
|
||||
$this->getAllServices();
|
||||
$this->getExtraPages();
|
||||
|
||||
}
|
||||
|
||||
public function getSeoSetting()
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
$seoSettings = Setting::where('setting_name', 'seo_setting')->get();
|
||||
if ($seoSettings->isNotEmpty()) {
|
||||
$settings = [];
|
||||
foreach ($seoSettings as $setting) {
|
||||
$settings[$setting->name] = $setting->detail;
|
||||
}
|
||||
view()->share('seoSetting', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getGeneralSetting()
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
$generalSettings = Setting::where('setting_name', 'general_setting')->get();
|
||||
if ($generalSettings->isNotEmpty()) {
|
||||
$settings = [];
|
||||
foreach ($generalSettings as $setting) {
|
||||
$settings[$setting->name] = $setting->detail;
|
||||
}
|
||||
view()->share('generalSetting', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdditionalSetting()
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
$additionalSettings = Setting::where('setting_name', 'additional_setting')->get();
|
||||
if ($additionalSettings->isNotEmpty()) {
|
||||
$settings = [];
|
||||
foreach ($additionalSettings as $setting) {
|
||||
$settings[$setting->name] = $setting->detail;
|
||||
}
|
||||
view()->share('additionalSetting', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- Social media share
|
||||
public function socialMediaShare()
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
$socialMediaShares = Setting::where('setting_name', 'social_setting')->get();
|
||||
if ($socialMediaShares->isNotEmpty()) {
|
||||
view()->share('socialMediaShareKey', compact('socialMediaShares'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- Social media share
|
||||
|
||||
|
||||
//-- Blog
|
||||
public function blog()
|
||||
{
|
||||
if (Schema::hasTable('blogs')) {
|
||||
$blogs = Blog::latest()->take(3)->get();
|
||||
if ($blogs->isNotEmpty()) {
|
||||
view()->share('blogkey', compact('blogs'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- Get site logo for backend
|
||||
public function getSiteImage()
|
||||
{
|
||||
View::composer('admin::layouts.master', function ($view) {
|
||||
$siteLogoSetting = Setting::where('setting_name', 'general_setting')
|
||||
->whereIn('name', ['primary_image', 'secondary_image'])
|
||||
->orderBy('id', 'ASC')
|
||||
->get();
|
||||
|
||||
if ($siteLogoSetting->isNotEmpty()) {
|
||||
$imageSetting = $siteLogoSetting->where('name', 'primary_image')->first();
|
||||
|
||||
if (is_null($imageSetting) || is_null($imageSetting->detail) || empty($imageSetting->detail)) {
|
||||
$imageSetting = $siteLogoSetting->where('name', 'secondary_image')->first();
|
||||
}
|
||||
|
||||
$siteLogo = asset('storage/uploads/' . optional($imageSetting)->detail);
|
||||
} else {
|
||||
$siteLogo = asset('backend/uploads/site_logo/defaultLogo.png');
|
||||
}
|
||||
|
||||
$view->with('siteLogo', $siteLogo);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//-- Get site logo for Frontend
|
||||
public function getMultipleSiteImage()
|
||||
{
|
||||
View::composer(
|
||||
// 'frontend.layouts.partials.header',
|
||||
'frontend.layouts.main',
|
||||
function ($view) {
|
||||
$view->with('primaryLogo', $this->getSiteLogo('primary_image'));
|
||||
$view->with('secondaryLogo', $this->getSiteLogo('secondary_image'));
|
||||
}
|
||||
);
|
||||
}
|
||||
public function getSiteLogo($imageName)
|
||||
{
|
||||
$siteLogoSetting = Setting::where('setting_name', 'general_setting')
|
||||
->whereIn('name', [$imageName])
|
||||
->first();
|
||||
|
||||
if ($siteLogoSetting && is_null($siteLogoSetting->detail) || empty($siteLogoSetting->detail)) {
|
||||
return asset('backend/uploads/site_logo/defaultLogo.png');
|
||||
} else {
|
||||
return asset('storage/uploads/' . $siteLogoSetting->detail);
|
||||
}
|
||||
}
|
||||
|
||||
public function getHairPosts()
|
||||
{
|
||||
if (Schema::hasTable('posts')) {
|
||||
$posts = Post::where('navbar_flag', '11')->orderBy('order', 'asc')->get();
|
||||
if ($posts->isNotEmpty()) {
|
||||
view()->share('hairPosts', $posts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllServices()
|
||||
{
|
||||
if (Schema::hasTable('services')) {
|
||||
$services = Service::where('status', 'active')->get();
|
||||
if ($services->isNotEmpty()) {
|
||||
view()->share('services', $services);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getExtraPages()
|
||||
{
|
||||
if (Schema::hasTable('pages')) {
|
||||
$models = Page::where('code', 'normal')->where('status', 'active')->get();
|
||||
if ($models->isNotEmpty()) {
|
||||
view()->share('extraPages', $models);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
app/Providers/AuthServiceProvider.php
Normal file
26
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
19
app/Providers/BroadcastServiceProvider.php
Normal file
19
app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
38
app/Providers/EventServiceProvider.php
Normal file
38
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
40
app/Providers/RouteServiceProvider.php
Normal file
40
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user