Run this command to install:
sail composer require impelevin/psp-sharedAdd a provider to a Service Provider:
IMPelevin\PSPShared\Providers\PSPSharedProvider::classExtend your Eloquent\Model from IMPelevin\PSPShared\LTree\Models\LTreeModel.
Run this command to publish migration create a table used by LTree:
sail artisan vendor:publish --tag=psp-ltree-migrationsUse LTreeService for build path:
- when create model:
lTreeCreatePath() - when update model:
lTreeUpdatePath()for update path for model and children - when delete model:
lTreeDropDescendants()for delete children models
The get() method returns LTreeCollection, instead of the usual Eloquent\Collection.
LTreeCollection has a toTree() method that converts a flat collection to a tree.
LTreeResourceCollection & LTreeResource, which take LTreeCollection as an argument, will also be useful.
Add to "App\Http\Kernel.php " middleware:
\IMPelevin\PSPShared\Inertia\Middleware\RedirectExternalLocation::classAdd to "App\Exceptions\Handler.php" trait:
use IMPelevin\PSPShared\Inertia\Exceptions\Traits\ErrorHandlingUse traits for models:
use IMPelevin\PSPShared\Formatters\CastAttributes\Traits\FullName;
use IMPelevin\PSPShared\Formatters\CastAttributes\Traits\FullAddress;
use IMPelevin\PSPShared\Formatters\CastAttributes\Traits\Gender;
use IMPelevin\PSPShared\Formatters\CastAttributes\Traits\Phone;
use IMPelevin\PSPShared\Traits\ApiResponse;Automatically find, translate and save missing translation keys:
sail artisan language:find-and-add