PHP code example of fuelviews / laravel-sabhero-wrapper

1. Go to this page and download the library: Download fuelviews/laravel-sabhero-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fuelviews / laravel-sabhero-wrapper example snippets


use Fuelviews\SabHeroWrapper\Models\Page;

// Create a new page
$page = Page::create([
    'title' => 'About Us',
    'slug' => 'about',
    'description' => 'Learn more about our company and mission.',
    'feature_image' => 'path/to/image.jpg'
]);

// Add feature image via media library
$page->addMediaFromUrl('https://example.com/image.jpg')
      ->toMediaCollection('page_feature_image');

// The page automatically provides SEO data
$seoData = $page->getDynamicSEOData();

// config/sabhero-wrapper.php
return [
    'livewire_enabled' => env('SABHERO_LIVEWIRE_ENABLED', true),
    'navigation_enabled' => env('SABHERO_NAVIGATION_ENABLED', true),
    'footer_enabled' => env('SABHERO_FOOTER_ENABLED', true),
    'forms_modal_enabled' => env('SABHERO_FORMS_MODAL_ENABLED', true),
    'gtm_enabled' => env('SABHERO_GTM_ENABLED', false),
];

use Fuelviews\SabHeroWrapper\Facades\SabHeroWrapper;

// Check if a feature is enabled
if (SabHeroWrapper::isFeatureEnabled('navigation_enabled')) {
    // Navigation is enabled
}

// Get all enabled features
$enabledFeatures = SabHeroWrapper::getEnabledFeatures();

// Get package version
$version = SabHeroWrapper::version();

// In your routes/web.php
Route::get('/', function () {
    return view('home');
})->name('home');

// The view composer will automatically look for a Page with slug 'home'
// and make it available as $seoPage in your views

'providers' => [
    // ...
    App\Providers\SabHeroWrapperServiceProvider::class,
],

$page = Page::find(1);

// Add feature image
$page->addMediaFromUrl('https://example.com/hero.jpg')
     ->toMediaCollection('page_feature_image');

// Get feature image URL
$imageUrl = $page->getFirstMediaUrl('page_feature_image');

// Get responsive images
$responsiveImages = $page->getFirstMedia('page_feature_image');
bash
# Publish configuration and migrations
php artisan vendor:publish --tag="sabhero-wrapper-config"
php artisan vendor:publish --tag="sabhero-wrapper-migrations"

# Run migrations
php artisan migrate
bash
# Publish views for customization
php artisan vendor:publish --tag="sabhero-wrapper-views"

# Publish seeders for sample data
php artisan vendor:publish --tag="sabhero-wrapper-seeders"

# Publish factories for testing
php artisan vendor:publish --tag="sabhero-wrapper-factories"

# Publish service provider for advanced customization
php artisan vendor:publish --tag="sabhero-wrapper-provider"
bash
php artisan vendor:publish --tag="sabhero-wrapper-provider"
bash
php artisan db:seed --class=PageTableSeeder
javascript
// tailwind.config.js
module.exports = {
    content: [        
        './resources/**/*.{js,vue,blade.php}',
        './vendor/fuelviews/laravel-sabhero-wrapper/resources/**/*.{blade.php,js,vue}',
    ],
    // ... rest of your configuration
}
bash
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
php artisan migrate