{"id":15105816,"url":"https://github.com/kanata-php/forklift","last_synced_at":"2026-01-18T20:32:36.238Z","repository":{"id":59117496,"uuid":"531078815","full_name":"kanata-php/forklift","owner":"kanata-php","description":"A Laravel Livewire Componet to move assets in folders","archived":false,"fork":false,"pushed_at":"2022-10-26T02:49:21.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T02:12:07.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanata-php.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["kanata-php"]}},"created_at":"2022-08-31T12:40:57.000Z","updated_at":"2025-01-04T18:00:26.000Z","dependencies_parsed_at":"2022-09-12T14:42:14.334Z","dependency_job_id":null,"html_url":"https://github.com/kanata-php/forklift","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kanata-php/forklift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fforklift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fforklift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fforklift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fforklift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanata-php","download_url":"https://codeload.github.com/kanata-php/forklift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanata-php%2Fforklift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28549832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T19:56:05.265Z","status":"ssl_error","status_checked_at":"2026-01-18T19:55:54.685Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T20:43:34.783Z","updated_at":"2026-01-18T20:32:36.221Z","avatar_url":"https://github.com/kanata-php.png","language":"PHP","funding_links":["https://github.com/sponsors/kanata-php"],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./docs/forklift.png\" height=\"200\"/\u003e\n\u003c/p\u003e\n\n# Forklift\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://github.com/kanata-php/forklift/actions/workflows/php.yml\"\u003e\u003cimg src=\"https://github.com/kanata-php/forklift/actions/workflows/php.yml/badge.svg\" alt=\"Tests\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/kanata-php/forklift\"\u003e\u003cimg src=\"https://codecov.io/gh/kanata-php/forklift/branch/master/graph/badge.svg?token=BEAL7MLFFA\" alt=\"Code Coverage\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Laravel Livewire Component\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./docs/screenshot.png\" /\u003e\n\u003c/p\u003e\n\n```shell\ncomposer require kanata-php/forklift\n```\n\nMove assets in a predictable and easy manner with Eloquent and Livewire.\n\n## Dependencies\n\n- Laravel\n- Livewire\n- AlpineJS\n\n## Installation\n\n**Step 1**\n\nInstall composer package:\n\n```shell\ncomposer require kanata-php/forklift\n```\n\n**Step 2**\n\nPublish the assets registered in the Service Provider:\n\n```shell\nphp artisan vendor:publish --provider=\"Kanata\\Forklift\\ForkliftServiceProvider\"\n```\n\nAfter this you'll find the assets at the directory `resources/views/vendor/forklift`. At the current version the initial assets are only presentable for projects usign [Tailwind CSS](https://tailwindcss.com/).\n\n**Step 3**\n\nImplement the `Kanata\\Forklift\\Interfaces\\AssetRepositoryInterface` for the component to know how to interact with your project's models. You'll create one per case (e.g. if you need to move nested directories, one repository, then if you need to move documents through directories, another repository).\n\nMethods:\n\n- `AssetRepositoryInterface::changeCurrentLocation` - This method returns current location's \"sub locations\". This is equivalent to sub folders when you have a folder based structure like a filesystem navigation.\n\n- `AssetRepositoryInterface::moveAsset` - This method executes the movement between locations of the asset being managed.\n\n- `AssetRepositoryInterface::findLocation` - This method finds the current location object.\n  \u003e The output must be an array with the following fields:\n  \u003e - id (int) - primary key\n  \u003e - title (string) - location's title\n  \u003e - parent (int) - parent location (for nested locations)\n\n## Usage\n\n### Basics\n\nLet's assume we have a filesystem structure. In this structure you have documents and directories. This package adds a dropdown that allows quickly moving assets in the directory structure.\n\nFor such, using eloquent, we would have the models:\n\n- **Directory** - that keeps the directories structure, having subdirectories and documents inside them.\n\u003e Example migration:\n\u003e ```php\n\u003e Schema::create('directories', function (Blueprint $table) {\n\u003e     $table-\u003eid();\n\u003e     $table-\u003estring('title', 40);\n\u003e     $table-\u003eforeignId('parent')-\u003enullable();\n\u003e     $table-\u003etimestamps();\n\u003e });\n\u003e ```\n\n- **Document** - that keeps the documents.\n\u003e Example migration:\n\u003e ```php\n\u003e Schema::create('documents', function (Blueprint $table) {\n\u003e     $table-\u003eid();\n\u003e     $table-\u003estring('title', 40);\n\u003e     $table-\u003elongText('content');\n\u003e     $table-\u003eforeignId('directory_id')-\u003enullable();\n\u003e     $table-\u003etimestamps();\n\u003e });\n\u003e ```\n\nThe following component is the **dropdown** to move documents:\n\n```html\n@livewire('forklift-dropdown', [\n    'currentLocationId' =\u003e $document-\u003edirectory_id,\n    'locationType' =\u003e \\App\\Models\\Directory::class,\n    'assetId' =\u003e $document-\u003eid,\n    'assetType' =\u003e \\App\\Models\\Document::class,\n    'assetRepository' =\u003e App\\Repositories\\DocumentAssetRepository::class,\n    'parentField' =\u003e 'directory_id',\n])\n```\n\nThe following component is the dropdown to move directories:\n\n```html\n@livewire('forklift-dropdown', [\n    'currentLocationId' =\u003e $directory-\u003eparent,\n    'locationType' =\u003e \\App\\Models\\Directory::class,\n    'assetId' =\u003e $directory-\u003eid,\n    'assetType' =\u003e \\App\\Models\\Directory::class,\n    'assetRepository' =\u003e App\\Repositories\\DirecotryAssetRepository::class,\n    'parentField' =\u003e 'parent',\n])\n```\n\nYou can find an example laravel project [here](https://github.com/kanata-php/forklift-example).\n\n### Events\n\nForklift dispatches 2 events, in 3 different levels. The 2 events are:\n\n- `Kanata\\Forklift\\Events\\AssetMoved` - Triggered after a successful return from the asset repository.\n- `Kanata\\Forklift\\Events\\AssetMoveFailed` - Triggered after a fail return from th asset repository.\n\nThe 3 levels that these events are dispatched are:\n\n- Laravel Events (https://laravel.com/docs/9.x/events#main-content)\n- Livewire Events (https://laravel-livewire.com/docs/2.x/events)\n- Browser events via Livewire (https://laravel-livewire.com/docs/2.x/events#browser)\n\n## Todo\n\n- Change UI when backend error happens.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanata-php%2Fforklift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanata-php%2Fforklift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanata-php%2Fforklift/lists"}