PHP code example of aiman / nest-tool
1. Go to this page and download the library: Download aiman/nest-tool 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/ */
aiman / nest-tool example snippets
use Aiman\ThaanaTextField\ThaanaTextField;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
//other fields
NestTool::make()
->usingModel(\App\Models\Topic::class)
->slug('slug')
->orderColumn('order')
->parentColumn('parent_id')
->displayName('topic')
->disable(false)
];
}
function parent(){
return $this->belongsTo('App\Models\Topic', 'parent_id');
}
function children(){
return $this->hasMany(self::class, 'parent_id')->orderBy('order')->with('children');
}