-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 25b400a
Showing
28 changed files
with
1,638 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Laravel.php Menu | ||
|
||
on: push | ||
|
||
jobs: | ||
cd: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: cd | ||
uses: tripteki/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repotoken: ${{ secrets.REPOSITORY_TOKEN }} | ||
repouser: tripteki | ||
repository: https://packagist.org | ||
language: php | ||
artifact: composer.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Trip Teknologi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<h1 align="center">Menu</h1> | ||
|
||
This package provides implementation of Menu in repository pattern for Lumen and Laravel besides REST API starterpack of admin management with no intervention to codebase and keep clean. | ||
|
||
Getting Started | ||
--- | ||
|
||
Installation : | ||
|
||
``` | ||
composer require tripteki/laravelphp-menu | ||
``` | ||
|
||
How to use it : | ||
|
||
- Put `Tripteki\Menu\Providers\MenuServiceProvider` to service provider configuration list. | ||
|
||
- Put `Tripteki\Menu\Providers\MenuServiceProvider::ignoreMigrations()` into `register` provider, then publish migrations file into your project's directory with running (optionally) : | ||
|
||
``` | ||
php artisan vendor:publish --tag=tripteki-laravelphp-menu-migrations | ||
``` | ||
|
||
- Migrate. | ||
|
||
``` | ||
php artisan migrate | ||
``` | ||
|
||
- Sample : | ||
|
||
```php | ||
use Tripteki\Menu\Contracts\Repository\Admin\IMenuAdminRepository; | ||
use Tripteki\Menu\Contracts\Repository\IMenuRepository; | ||
|
||
$menuAdminRepository = app(IMenuAdminRepository::class); | ||
|
||
// $menuAdminRepository->create([ "platform" => "desktop", "route" => "/ads", "nth" => 0, "title" => "ads_gallery", "icon" => "md-gallery", "description" => "Gallery", ]); // | ||
// $menuAdminRepository->delete("identifier"); // | ||
// $menuAdminRepository->update("identifier", [ "platform" => "desktop", "route" => "/ads", "nth" => 1, "title" => "ads_gallery", "icon" => "md-gallery", "description" => "Gallery", ]); // | ||
// $menuAdminRepository->activate("identifier"); // | ||
// $menuAdminRepository->deactivate("identifier"); // | ||
// $menuAdminRepository->get("identifier"); // | ||
// $menuAdminRepository->all(); // | ||
|
||
$repository = app(IMenuRepository::class); | ||
|
||
// $repository->get("desktop", "/ads", 5); // | ||
// $repository->all("web", "/ads"); // | ||
// $repository->all("mobile", "/ads"); // | ||
// $repository->all("desktop", "/ads"); // | ||
``` | ||
|
||
- Generate swagger files into your project's directory with putting this into your annotation configuration (optionally) : | ||
|
||
``` | ||
base_path("app/Http/Controllers/Menu") | ||
``` | ||
|
||
``` | ||
base_path("app/Http/Controllers/Admin/Menu") | ||
``` | ||
|
||
Usage | ||
--- | ||
|
||
`php artisan adminer:install:menu` | ||
|
||
Author | ||
--- | ||
|
||
- Trip Teknologi ([@tripteki](https://linkedin.com/company/tripteki)) | ||
- Hasby Maulana ([@hsbmaulana](https://linkedin.com/in/hsbmaulana)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "tripteki/laravelphp-menu", | ||
"version": "1.0.0", | ||
"description": "Trip Teknologi's Laravel.php Menus", | ||
|
||
"readme": "README.md", | ||
"license": "MIT", | ||
"authors": [ { "name": "Trip Teknologi", "email": "[email protected]" } ], | ||
"homepage": "https://github.com/tripteki/laravelphp-menu", | ||
"support": { "issues": "https://github.com/tripteki/laravelphp-menu/issues" }, | ||
|
||
"require": { | ||
|
||
"php": "^8.0.2", | ||
|
||
"tripteki/laravelphp-repository": "^1.0.0", | ||
"tripteki/laravelphp-helpers": "^1.0.0", | ||
"tripteki/laravelphp-adminer": "^1.0.0", | ||
"tripteki/laravelphp-import-export": "^1.0.0", | ||
"tripteki/laravelphp-request-response-query": "^1.0.0" | ||
}, | ||
|
||
"require-dev": {}, | ||
|
||
"suggest": { | ||
|
||
"laravel/lumen-framework": "Required when using lumen framework (^9.0).", | ||
"laravel/framework": "Required when using laravel framework (^9.0)." | ||
}, | ||
|
||
"autoload": { | ||
|
||
"psr-4": { | ||
|
||
"Tripteki\\Menu\\": "src/" | ||
} | ||
}, | ||
|
||
"autoload-dev": {}, | ||
|
||
"extra": { | ||
|
||
"laravel": { | ||
|
||
"dont-discover": [], | ||
|
||
"providers": [ | ||
|
||
"Tripteki\\Menu\\Providers\\MenuServiceProvider" | ||
], | ||
|
||
"aliases": [] | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
database/migrations/2023_01_15_000001_create_menus_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateMenusTable extends Migration | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create("menus", function (Blueprint $table) { | ||
|
||
$table->uuid("id"); | ||
|
||
$table->string("platform"); | ||
$table->string("route"); | ||
$table->integer("nth")->default(0); | ||
$table->string("title"); | ||
$table->string("icon")->nullable(true); | ||
$table->text("description")->nullable(true); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
|
||
$table->primary("id"); | ||
$table->unique([ "platform", "route", "title", ]); | ||
}); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists("menus"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Tripteki\Menu\Console\Commands; | ||
|
||
use Tripteki\Helpers\Helpers\ProjectHelper; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Console\Command; | ||
|
||
class InstallCommand extends Command | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $signature = "adminer:install:menu"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = "Install the menu stack"; | ||
|
||
/** | ||
* @var \Tripteki\Helpers\Helpers\ProjectHelper | ||
*/ | ||
protected $helper; | ||
|
||
/** | ||
* @param \Tripteki\Helpers\Helpers\ProjectHelper $helper | ||
* @return void | ||
*/ | ||
public function __construct(ProjectHelper $helper) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->helper = $helper; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$this->installStack(); | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
protected function installStack() | ||
{ | ||
(new Filesystem)->ensureDirectoryExists(base_path("routes/user")); | ||
(new Filesystem)->ensureDirectoryExists(base_path("routes/admin")); | ||
(new Filesystem)->copy(__DIR__."/../../../stubs/routes/user/menu.php", base_path("routes/user/menu.php")); | ||
(new Filesystem)->copy(__DIR__."/../../../stubs/routes/admin/menu.php", base_path("routes/admin/menu.php")); | ||
$this->helper->putRoute("api.php", "user/menu.php"); | ||
$this->helper->putRoute("api.php", "admin/menu.php"); | ||
|
||
(new Filesystem)->ensureDirectoryExists(app_path("Http/Controllers/Menu")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Controllers/Menu", app_path("Http/Controllers/Menu")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Http/Requests/Menus")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Requests/Menus", app_path("Http/Requests/Menus")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Http/Controllers/Admin/Menu")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Controllers/Admin/Menu", app_path("Http/Controllers/Admin/Menu")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Imports/Menus")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Imports/Menus", app_path("Imports/Menus")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Exports/Menus")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Exports/Menus", app_path("Exports/Menus")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Http/Requests/Admin/Menus")); | ||
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Requests/Admin/Menus", app_path("Http/Requests/Admin/Menus")); | ||
(new Filesystem)->ensureDirectoryExists(app_path("Http/Responses")); | ||
|
||
$this->info("Adminer Menu scaffolding installed successfully."); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Tripteki\Menu\Contracts\Repository\Admin; | ||
|
||
use Tripteki\Repository\Contracts\Allable; | ||
use Tripteki\Repository\Contracts\Getable; | ||
use Tripteki\Repository\Contracts\Createable; | ||
use Tripteki\Repository\Contracts\Updateable; | ||
use Tripteki\Repository\Contracts\Deleteable; | ||
|
||
interface IMenuAdminRepository extends Allable, Getable, Createable, Updateable, Deleteable | ||
{ | ||
// | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Tripteki\Menu\Contracts\Repository; | ||
|
||
use Tripteki\Repository\Contracts\Allable; | ||
use Tripteki\Repository\Contracts\Getable; | ||
|
||
interface IMenuRepository | ||
{ | ||
// | ||
}; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Tripteki\Menu\Models; | ||
|
||
use Tripteki\Uid\Traits\UniqueIdTrait; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Menu extends Model | ||
{ | ||
use UniqueIdTrait, SoftDeletes; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
|
||
"platform", | ||
"route", | ||
"nth", | ||
"title", | ||
"icon", | ||
"description", | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $hidden = []; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function activate() | ||
{ | ||
$this->restore(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function deactivate() | ||
{ | ||
$this->delete(); | ||
} | ||
}; |
Oops, something went wrong.