Skip to content

Commit

Permalink
build(core): initial
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbmaulana committed Oct 15, 2023
0 parents commit ebfac3d
Show file tree
Hide file tree
Showing 40 changed files with 2,366 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Laravel.php Setting 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
21 changes: 21 additions & 0 deletions LICENSE
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.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<h1 align="center">Setting Menu</h1>

This package provides implementation of setting 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-setting-menu
```

How to use it :

- Put `Tripteki\SettingMenu\Providers\SettingMenuServiceProvider` to service provider configuration list.

- Put `Tripteki\SettingMenu\Providers\SettingMenuServiceProvider::ignoreMigrations()` into `register` provider, then publish migrations file into your project's directory with running (optionally) :

```
php artisan vendor:publish --tag=tripteki-laravelphp-setting-menu-migrations
```

- Migrate.

```
$ php artisan migrate
```

- Publish tests file into your project's directory with running (optionally) :

```
php artisan vendor:publish --tag=tripteki-laravelphp-setting-menu-tests
```

- Sample :

```php
use Tripteki\SettingMenu\Contracts\Repository\Admin\ISettingMenuDetailRepository;
use Tripteki\SettingMenu\Contracts\Repository\ISettingMenuRepository;

$menuRepository = app(ISettingMenuDetailRepository::class);

// $menuRepository->create("headernavbar", "home", [ "category" => "base", "icon" => "md-home", "title" => "Home", "description" => "Home Page", ]); //
// $menuRepository->delete("headernavbar", "home"); //
// $menuRepository->update("headernavbar", "home", [ "icon" => "fa-home", ]); //
// $menuRepository->get("headernavbar", "home"); //
// $menuRepository->all("headernavbar"); //

$repository = app(ISettingMenuRepository::class);
// $repository->setUser(...); //
// $repository->getUser(); //

// $repository->move(null, "dashboard", "sidenavbar"); //
// $repository->move(null, "home", "headernavbar"); //
// $repository->move(null, "profile", "headernavbar"); //
// $repository->move(null, "about", "headernavbar"); //
// $repository->move(null, "media", "sidenavbar"); //
// $repository->move("media", null, "sidenavbar"); //
// $repository->move("about", null, "headernavbar"); //
// $repository->move("profile", null, "headernavbar"); //
// $repository->move("home", null, "headernavbar"); //
// $repository->move("dashboard", null, "sidenavbar"); //
// $repository->move("media", "dashboard", "sidenavbar"); //
// $repository->move("profile", "home", "headernavbar"); //
// $repository->move("about", "home.profile", "headernavbar"); //
// $repository->move("home.profile.about", "home", "headernavbar"); //
// $repository->all(); //
```

- Generate swagger files into your project's directory with putting this into your annotation configuration (optionally) :

```
base_path("app/Http/Controllers/SettingMenu")
```

```
base_path("app/Http/Controllers/Admin/SettingMenu")
```

Usage
---

`php artisan adminer:install:setting:menu`

Author
---

- Trip Teknologi ([@tripteki](https://linkedin.com/company/tripteki))
- Hasby Maulana ([@hsbmaulana](https://linkedin.com/in/hsbmaulana))
58 changes: 58 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "tripteki/laravelphp-setting-menu",
"version": "1.0.0",
"description": "Trip Teknologi's Laravel.php Setting Menu",

"readme": "README.md",
"license": "MIT",
"authors": [ { "name": "Trip Teknologi", "email": "[email protected]" } ],
"homepage": "https://github.com/tripteki/laravelphp-setting-menu",
"support": { "issues": "https://github.com/tripteki/laravelphp-setting-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-setting": "^1.0.0",
"tripteki/laravelphp-import-export": "^1.0.0",
"tripteki/laravelphp-request-response-query": "^1.0.0",

"awobaz/compoships": "^2.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\\SettingMenu\\": "src/"
}
},

"autoload-dev": {},

"extra": {

"laravel": {

"dont-discover": [],

"providers": [

"Tripteki\\SettingMenu\\Providers\\SettingMenuServiceProvider"
],

"aliases": []
}
}
}
35 changes: 35 additions & 0 deletions database/migrations/2023_01_15_000000_create_menus_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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->string("menuable_type");
$table->string("menuable_id");

$table->string("category");
$table->string("icon");
$table->string("title");
$table->text("description");

$table->primary([ "menuable_type", "menuable_id", ]);
});
}

/**
* @return void
*/
public function down()
{
Schema::dropIfExists("menus");
}
};
79 changes: 79 additions & 0 deletions src/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace Tripteki\SettingMenu\Console\Commands;

use Tripteki\Helpers\Contracts\AuthModelContract;
use Tripteki\Helpers\Helpers\ProjectHelper;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Console\Command;

class InstallCommand extends Command
{
/**
* @var string
*/
protected $signature = "adminer:install:setting:menu";

/**
* @var string
*/
protected $description = "Install the setting 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->call("adminer:install:setting");
$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/setting/menu.php", base_path("routes/user/setting/menu.php"));
(new Filesystem)->copy(__DIR__."/../../../stubs/routes/admin/setting/menu.php", base_path("routes/admin/setting/menu.php"));
$this->helper->putRoute("api.php", "user/setting/menu.php");
$this->helper->putRoute("api.php", "admin/setting/menu.php");

(new Filesystem)->ensureDirectoryExists(app_path("Http/Controllers/Setting/Menu"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Controllers/Setting/Menu", app_path("Http/Controllers/Setting/Menu"));
(new Filesystem)->ensureDirectoryExists(app_path("Http/Requests/Settings/Menus"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Requests/Settings/Menus", app_path("Http/Requests/Settings/Menus"));
(new Filesystem)->ensureDirectoryExists(app_path("Http/Controllers/Admin/Setting/Menu"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Controllers/Admin/Setting/Menu", app_path("Http/Controllers/Admin/Setting/Menu"));
(new Filesystem)->ensureDirectoryExists(app_path("Imports/Settings/Menus"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Imports/Settings/Menus", app_path("Imports/Settings/Menus"));
(new Filesystem)->ensureDirectoryExists(app_path("Exports/Settings/Menus"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Exports/Settings/Menus", app_path("Exports/Settings/Menus"));
(new Filesystem)->ensureDirectoryExists(app_path("Http/Requests/Admin/Settings/Menus"));
(new Filesystem)->copyDirectory(__DIR__."/../../../stubs/app/Http/Requests/Admin/Settings/Menus", app_path("Http/Requests/Admin/Settings/Menus"));
(new Filesystem)->ensureDirectoryExists(app_path("Http/Responses"));

$this->helper->putTrait($this->helper->classToFile(get_class(app(AuthModelContract::class))), \Tripteki\SettingMenu\Traits\MenuTrait::class);

$this->info("Adminer Setting Menu scaffolding installed successfully.");
}
};
14 changes: 14 additions & 0 deletions src/Contracts/Repository/Admin/ISettingMenuDetailRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tripteki\SettingMenu\Contracts\Repository\Admin;

use Tripteki\Repository\Contracts\Allable;
use Tripteki\Repository\Contracts\Getable;
use Tripteki\Repository\Contracts\Updateable;
use Tripteki\Repository\Contracts\Createable;
use Tripteki\Repository\Contracts\Deleteable;

interface ISettingMenuDetailRepository
{
//
};
12 changes: 12 additions & 0 deletions src/Contracts/Repository/ISettingMenuRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Tripteki\SettingMenu\Contracts\Repository;

use Tripteki\Repository\Contracts\Allable;
use Tripteki\Repository\Contracts\Updateable;
use Tripteki\Repository\Contracts\Deleteable;

interface ISettingMenuRepository extends Allable
{
//
};
24 changes: 24 additions & 0 deletions src/Events/Placed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Tripteki\SettingMenu\Events;

use Illuminate\Queue\SerializesModels as SerializationTrait;

class Placed
{
use SerializationTrait;

/**
* @var mixed
*/
public $data;

/**
* @param mixed $data
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
};
24 changes: 24 additions & 0 deletions src/Events/Placing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Tripteki\SettingMenu\Events;

use Illuminate\Queue\SerializesModels as SerializationTrait;

class Placing
{
use SerializationTrait;

/**
* @var \Illuminate\Http\Request
*/
public $data;

/**
* @param \Illuminate\Http\Request $data
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
};
Loading

0 comments on commit ebfac3d

Please sign in to comment.