wip
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\InventoryHistoryItems;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Nova\Events\ServingNova;
|
||||
use Laravel\Nova\Nova;
|
||||
|
||||
class FieldServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Nova::serving(function (ServingNova $event) {
|
||||
Nova::script('inventory-history-items', __DIR__.'/../dist/js/field.js');
|
||||
Nova::style('inventory-history-items', __DIR__.'/../dist/css/field.css');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\InventoryHistoryItems;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Nova\Fields\Field;
|
||||
use Laravel\Nova\Fields\SupportsDependentFields;
|
||||
|
||||
class InventoryHistoryItems extends Field
|
||||
{
|
||||
use SupportsDependentFields;
|
||||
|
||||
/**
|
||||
* The field's component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component = 'inventory-history-items';
|
||||
|
||||
/**
|
||||
* Set the options for the select menu.
|
||||
*
|
||||
* @param array<string|int, array<string, mixed>|string>|\Closure|callable|\Illuminate\Support\Collection $options
|
||||
* @return $this
|
||||
*
|
||||
* @phpstan-param TOption|(callable(): (TOption))|(\Closure(): (TOption)) $options
|
||||
*/
|
||||
public function options(array|Collection $options): self
|
||||
{
|
||||
return $this->withMeta([
|
||||
'options' => $this->serializeOptions($options),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize Options
|
||||
*
|
||||
* @param Collection $options
|
||||
*/
|
||||
public function serializeOptions(array|Collection $options): array|Collection
|
||||
{
|
||||
return collect($options)->map(fn ($label, $value) => ['label' => $label, 'value' => $value]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user