1. Go to this page and download the library: Download sjorsvanleeuwen/webmixx 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/ */
sjorsvanleeuwen / webmixx example snippets
namespace App\WebmixxModules;
use App\Models\News;
use SjorsvanLeeuwen\Webmixx\Contracts\ModuleSetFieldType;
use Traversable;
class ThreeMostRecentNewsArticles implements ModuleSetFieldType
{
public static function getModuleDisplayName() : string{
return '3 Most Recent News Articles';
}
public function getIterator() : Traversable{
return News::query()
->orderByDesc('created_at')
->take(3)
->get();
}
}
public function boot(): void
{
Webmixx::addPageModule(new ThreeMostRecentNewsArticles());
}
declare(strict_types=1);
namespace App\WebmixxModules;
use App\Models\Slideshow;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use SjorsvanLeeuwen\Webmixx\Contracts\ModuleItemFieldType;
class PageSlideshowProvider implements ModuleItemFieldType
{
public static function getModuleDisplayName(): string
{
return 'Page header slideshow';
}
public static function getSelectList(): Collection
{
return Slideshow::query()
->get();
}
public function getItem(int $value): Model
{
return self::getSelectList()->firstWhere('id', $value);
}
}
public function boot(): void
{
Webmixx::addPageModule(new PageSlideshowProvider());
}