Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 75 additions & 6 deletions stubs/resource.stub
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,124 @@
namespace {{ namespace }};

use Orchid\Crud\Resource;
use Orchid\Crud\Filters\DefaultSorted;
use Orchid\Screen\TD;
use Illuminate\Support\Str;
use Orchid\Screen\Actions\Link;
use Orchid\Screen\Fields\Input;

class {{ class }} extends Resource
{
/**
* The model the resource corresponds to.
* The model that this resource corresponds to.
*
* @var string
*/
public static $model = '';

/**
* Get the fields displayed by the resource.
* Get the displayable singular label of the resource.
*
* @return string
*/
// public static function singularLabel()
// {
// return __('Post');
// }

/**
* Text to show in the side menu, breadcrumbs and top of content area
*
* @var string
*/
// public static function label(): string
// {
// return "<H1> of the page";
// }

/**
* Description right under the label at top of content area
*
* @var string
*/
// public static function description(): ?string
// {
// return "Text under the <H1>";
// }

/**
* Indicates whether should check for modifications between viewing and updating a resource.
*
* @return bool
*/
public static function trafficCop(): bool
{
return false;
}

/**
* Declares how the resource columns are edited
*
* @return array
*/
public function fields(): array
{
return [];
return [
// Input::make('name')
// ->title('Name')
// ->disabled()
// ->placeholder('Enter Name here'),
];
}

/**
* Get the columns displayed by the resource.
* Declares the columns and their order when browsing the resource.
*
* @return TD[]
*/
public function columns(): array
{
return [
TD::make('id'),
TD::make('id')
->sort()
->filter(TD::FILTER_NUMERIC)
->render(function ($model) {
return Link::make($model->id)
->route('platform.resource.edit', [Str::kebab('{{ class }}'), $model->id]);
}),

TD::make('created_at', 'Date of creation')
->sort()
->render(function ($model) {
return $model->created_at->toDateTimeString();
}),

TD::make('updated_at', 'Update date')
->sort()
->render(function ($model) {
return $model->updated_at->toDateTimeString();
}),
];
}

/**
* Get the filters available for the resource.
* Define the filters available for the entire resource
*
* @return array
*/
public function filters(): array
{
return [
new DefaultSorted('id', 'desc'),
];
}

/**
* Get the actions available for the resource.
*
* @return array
*/
public function actions(): array
{
return [];
}
Expand Down