-
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 35fed63
Showing
25 changed files
with
1,374 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,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", ]); | ||
}); | ||
} | ||
|
||
/** | ||
* @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(); | ||
} | ||
}; |
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,103 @@ | ||
<?php | ||
|
||
namespace Tripteki\Menu\Providers; | ||
|
||
use Tripteki\Menu\Models\Menu; | ||
use Tripteki\Uid\Observers\UniqueIdObserver; | ||
use Tripteki\Menu\Console\Commands\InstallCommand; | ||
use Tripteki\Repository\Providers\RepositoryServiceProvider as ServiceProvider; | ||
|
||
class MenuServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $repositories = | ||
[ | ||
\Tripteki\Menu\Contracts\Repository\IMenuRepository::class => \Tripteki\Menu\Repositories\Eloquent\MenuRepository::class, | ||
\Tripteki\Menu\Contracts\Repository\Admin\IMenuAdminRepository::class => \Tripteki\Menu\Repositories\Eloquent\Admin\MenuAdminRepository::class, | ||
]; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
public static $runsMigrations = true; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public static function shouldRunMigrations() | ||
{ | ||
return static::$runsMigrations; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public static function ignoreMigrations() | ||
{ | ||
static::$runsMigrations = false; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
parent::boot(); | ||
|
||
$this->dataEventListener(); | ||
|
||
$this->registerPublishers(); | ||
$this->registerCommands(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function registerCommands() | ||
{ | ||
if (! $this->app->isProduction() && $this->app->runningInConsole()) { | ||
|
||
$this->commands( | ||
[ | ||
InstallCommand::class, | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function registerMigrations() | ||
{ | ||
if ($this->app->runningInConsole() && static::shouldRunMigrations()) { | ||
|
||
$this->loadMigrationsFrom(__DIR__."/../../database/migrations"); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function registerPublishers() | ||
{ | ||
if (! static::shouldRunMigrations()) { | ||
|
||
$this->publishes( | ||
[ | ||
__DIR__."/../../database/migrations" => database_path("migrations"), | ||
], | ||
|
||
"tripteki-laravelphp-menu-migrations"); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function dataEventListener() | ||
{ | ||
Menu::observe(UniqueIdObserver::class); | ||
} | ||
}; |
Oops, something went wrong.