wip
This commit is contained in:
33
nova-components/PayoutProducts/src/FieldServiceProvider.php
Normal file
33
nova-components/PayoutProducts/src/FieldServiceProvider.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\PayoutProducts;
|
||||
|
||||
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('payout-products', __DIR__.'/../dist/js/field.js');
|
||||
Nova::style('payout-products', __DIR__.'/../dist/css/field.css');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
38
nova-components/PayoutProducts/src/PayoutProducts.php
Normal file
38
nova-components/PayoutProducts/src/PayoutProducts.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\PayoutProducts;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Nova\Fields\Field;
|
||||
use Laravel\Nova\Fields\SupportsDependentFields;
|
||||
|
||||
class PayoutProducts extends Field
|
||||
{
|
||||
use SupportsDependentFields;
|
||||
|
||||
/**
|
||||
* The field's component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component = 'payout-products';
|
||||
|
||||
/**
|
||||
* Products to be rendered
|
||||
*
|
||||
* @param array $products
|
||||
*/
|
||||
public function products(array|callable|Collection $products): self
|
||||
{
|
||||
if (is_callable($products)) {
|
||||
$products = call_user_func($products);
|
||||
}
|
||||
|
||||
if ($products instanceof Arrayable) {
|
||||
$products = $products->toArray();
|
||||
}
|
||||
|
||||
return $this->withMeta(['products' => $products]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user