Revision 482 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpnamespace App\Http\Controllers\online_shop;use App\Http\Controllers\Controller;use App\Models\Directory;use Illuminate\Http\Request;use Illuminate\Contracts\Foundation\Application;use Illuminate\Contracts\View\Factory;use Illuminate\Contracts\View\View;class TreeController extends Controller{public function show( Request $request ){$id = $request->id;if ( !$id ){$id = "-1";}$d = Directory::where( "id", $id )->withCount('sub_dirs')->with('medium.medium')->get();$d = $d[0];$d->text = $d->name;$d->state = "closed";$d->children = (bool)($d->sub_dirs_count >= 1);$d->children = Directory::where( "directory_id", $id )->withCount('sub_dirs')->with('medium.medium')->get()->each( function ( $d ){$d->text = $d->name;$d->state = "closed";$d->children = (bool)($d->sub_dirs_count >= 1);$d->url = "/Online-Shop/tree/?id=" . $d->id;} );return json_encode( $d );}}