Skip to content

Instantly share code, notes, and snippets.

@scramatte
Last active May 1, 2024 17:06
Show Gist options
  • Select an option

  • Save scramatte/0c3c8e2b0f6e5f06377abe93fd7f3045 to your computer and use it in GitHub Desktop.

Select an option

Save scramatte/0c3c8e2b0f6e5f06377abe93fd7f3045 to your computer and use it in GitHub Desktop.
Product Nova Resource
<?php
namespace Modules\Billing\Nova\Resources\Product;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\BelongsTo;
use ZakariaTlilani\NovaNestedTree\NestedTreeAttachManyField;
use Modules\Billing\Models\Product as ProductModels;
use Modules\Billing\Nova\Resources\Resource;
use Modules\Billing\Nova\Resources as BillingResources;
class Product extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = ProductModels\Product::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id',
];
/**
* Get the fields displayed by the resource.
*
* @return array
*/
public function fields(Request $request)
{
return [
BelongsTo::make(__('billing.product_family'),'family',ProductFamily::class),
NestedTreeAttachManyField::make(__('billing.product_family'),'family',ProductFamily::class)
->useSingleSelect(),
Text::make(__('billing.product_name'), 'name'),
];
}
/**
* Get the cards available for the request.
*
* @return array
*/
public function cards(Request $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* @return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @return array
*/
public function actions(Request $request)
{
return [];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment