Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sharp Laravel Package

code16/sharp

Code-driven CMS framework for Laravel (PHP 8.3+/Laravel 11+). Build admin/CMS sections with a clean UI and strong DX: CRUD with validation, search/sort/filter, bulk or custom commands, and authorization—no front-end code required, data-agnostic.

View on GitHub
Deep Wiki
Context7

Ordered list widget

This widget intends to display data as an ordered list of items

$widgetsContainer->addWidget(
    SharpOrderedListWidget::make('bestSellers')
);

Data valuation

Valuation is handled by a dedicated $this->setOrderedListData(string $panelWidgetKey, array $data) in the Dashboard class:

function buildWidgetsData(): void
{
    $this->setOrderedListData(
        'bestSellers', [
            [
                'label' => 'model EF5978',
                'count' => 89
            ],
            [
                'label' => 'model TT4448',
            ],
            [
                'label' => 'model EF5978',
                'count' => 17
            ],
            [
                'label' => 'model YY5557'
            ]
        ]
    );
}

Pass there the widget key and an array with the data as an array. Each item of the array should be an associative array. The key label is mandatory as it defines the ordered list item main content. You can also optionally define a count with key count associated with a number, it will show a badge with given value.

Here's a more realistic example with data fetched from a Model:

$this->setOrderedListData(
    'bestSellers',
    Product::orderBy('sales_count', 'desc')
        ->take(5)
        ->get()
        ->map(function (Product $product) {
            return [
                'id' => $product->id,
                'label' => $product->name,
                'count' => $product->sales_count,
            ];
        })
        ->values()
        ->all()
);

Item URL

You may want to add a link on each row. To do that, use the buildItemLink() method on the widget creation:

$widgetsContainer->addWidget(
    SharpOrderedListWidget::make('bestSellers')
            ->buildItemLink(fn ($item) => url('some-link'))
);

In order to make a link to a Sharp EntityList, Show or Form, this method can also return a LinkTo instance:

$widgetsContainer->addWidget(
    SharpOrderedListWidget::make('bestSellers')
        ->buildItemLink(function ($item) {
            return LinkToShowPage::make('products', $item['id']); 
        })
);

As you can see, the link is built for each row, and is therefore data-dependant.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle