PHP code example of skylive / lienzo

1. Go to this page and download the library: Download skylive/lienzo 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/ */

    

skylive / lienzo example snippets


    use Illuminate\Support\Facades\Gate;
    use Skylive\Lienzo\Models\Site;

    Gate::define('lienzo.manage', fn (User $user, Site $site): bool => $user->is_admin);
    

    use Skylive\Lienzo\Models\Site;

    Route::middleware('auth')->group(function () {
        Route::get('admin', fn () => view('admin', ['site' => Site::default()]))->name('admin');
        Route::lienzoEditor('admin/site');
    });

    Route::lienzo();
    

return Inertia::render('SiteEditor', [
    'editorScript' => Lienzo::editorScriptUrl(),
    'endpoint' => route('lienzo.editor', ['lienzoSite' => $site]),
]);

Lienzo::resolveSiteUsing(function (Request $request): ?Site {
    $team = Team::firstWhere('domain', $request->getHost());

    return $team === null ? null : Site::forOwner($team);
});

use Skylive\Lienzo\Element;
use Skylive\Lienzo\Field;

class LatestPosts extends Element
{
    protected string $type = 'latest_posts';
    protected string|array $label = ['en' => 'Latest posts', 'es' => 'Últimas entradas'];
    protected string $icon = 'file-text';

    public function fields(): array
    {
        return [
            Field::text('heading', 'Heading', max: 60)->default('From the blog'),
            Field::number('count', 'How many', min: 1, max: 6)->default(3),
        ];
    }

    public function render(array $props, Site $site): Htmlable
    {
        return view('elements.latest-posts', [
            'heading' => $props['heading'],
            'posts' => Post::latest()->limit($props['count'])->get(),
        ]);
    }
}

Lienzo::element(LatestPosts::class);

Lienzo::action(
    'book',
    'Book a visit',
    fn (?string $service, Site $site): ?string => $service ? route('booking', $service) : null,
    Field::text('service', 'Service'),
);

Lienzo::siteFields(Field::text('phone', 'Phone number', max: 30));
sh
    php artisan lienzo:install
    php artisan migrate
    
blade
    <x-lienzo::editor :site="$site" style="display:block;height:100vh" />