PHP code example of lee-to / moonshine-tree-resource
1. Go to this page and download the library: Download lee-to/moonshine-tree-resource library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lee-to / moonshine-tree-resource example snippets
use Leeto\MoonShineTree\Resources\TreeResource;
class CategoryResource extends TreeResource
{
// Required
protected string $column = 'title';
protected string $sortColumn = 'sorting';
protected function pages(): array
{
return [
CategoryTreePage::class,
FormPage::class,
DetailPage::class,
];
}
// ... fields, model, etc ...
public function treeKey(): ?string
{
return 'parent_id';
}
public function sortKey(): string
{
return 'sorting';
}
// ...
}
namespace App\MoonShine\Pages;
use Leeto\MoonShineTree\View\Components\TreeComponent;
use MoonShine\Laravel\Pages\Crud\IndexPage;
class CategoryTreePage extends IndexPage
{
protected function mainLayer(): array
{
return [
...$this->getPageButtons(),
TreeComponent::make($this->getResource()),
];
}
}
protected string $sortColumn = 'sorting';
public function modifyListComponent(ComponentContract $component): ComponentContract
{
return TreeComponent::make($this);
}
use Leeto\MoonShineTree\Resources\TreeResource;
class CategoryResource extends TreeResource
{
// Required
protected string $column = 'title';
protected string $sortColumn = 'sorting';
// ... fields, model, etc ...
public function treeKey(): ?string
{
return null;
}
public function sortKey(): string
{
return 'sorting';
}
// ...
}
public function itemContent(Model $item): string
{
return 'Custom content here';
}
public function wrapable(): bool
{
return false;
}
public function sortable(): bool
{
return false;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.