PHP code example of invaders-xx / filament-nested-list
1. Go to this page and download the library: Download invaders-xx/filament-nested-list 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/ */
invaders-xx / filament-nested-list example snippets
return [
/**
* Tree model fields
*/
'column_name' => [
'order' => 'order',
'parent' => 'parent_id',
'title' => 'title',
],
/**
* Tree model default parent key
*/
'default_parent_id' => -1,
/**
* Tree model default children key name
*/
'default_children_key_name' => 'children',
];
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use InvadersXX\FilamentNestedList\Concern\ModelNestedList;
class ProductCategory extends Model
{
use ModelNestedList;
protected $fillable = ["parent_id", "title", "order"];
protected $table = 'product_categories';
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use InvadersXX\FilamentNestedList\Concern\ModelNestedList;
class ProductCategory extends Model
{
use ModelNestedList;
protected $fillable = ["parent_id", "title", "order"];
protected $table = 'product_categories';
// Default if you need to override
// public function determineOrderColumnName(): string
// {
// return "order";
// }
// public function determineParentColumnName(): string
// {
// return "parent_id";
// }
// public function determineTitleColumnName(): string
// {
// return 'title';
// }
// public static function defaultParentKey()
// {
// return -1;
// }
// public static function defaultChildrenKeyName(): string
// {
// return "children";
// }
}