Skip to content

[Aldy] Module Add On Feature #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
5 changes: 5 additions & 0 deletions Modules/AddOnFeature/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => 'Add On Feature'
];
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Modules\AddOnFeature\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class AddOnFeatureDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();

// $this->call("OthersTableSeeder");
}
}
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions Modules/AddOnFeature/Entities/AddOnFeature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Modules\AddOnFeature\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class AddOnFeature extends Model
{
use HasFactory;

protected $fillable = [];

protected static function newFactory()
{
return \Modules\AddOnFeature\Database\factories\AddOnFeatureFactory::new();
}
}
55 changes: 55 additions & 0 deletions Modules/AddOnFeature/Entities/AddOnFeatureDatatables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Modules\AddOnFeature\Entities;

use App\Models\Model;
use Hexters\Ladmin\Datatables\Datatables;
use Hexters\Ladmin\Contracts\DataTablesInterface;

class AddOnFeatureDatatables extends Datatables implements DataTablesInterface {

/**
* Datatables function
*/
public function render() {

/**
* Data from controller
*/
$data = self::$data;

return $this->eloquent(Model::query())
->escapeColumns([])
->make(true);
}

/**
* Datatables Option
*/
public function options() {

/**
* Data from controller
*/
$data = self::$data;

return [
'title' => 'List Of Model',
'buttons' => null, // e.g : view('user.actions.create')
'fields' => [ __('ID'), ], // Table header
/**
* DataTables Options
*/
'options' => [
'processing' => true,
'serverSide' => true,
'ajax' => request()->fullurl(),
'columns' => [
['data' => 'id', 'class' => 'text-center'],
]
]
];

}

}
Empty file.
94 changes: 94 additions & 0 deletions Modules/AddOnFeature/Http/Controllers/AddOnFeatureController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace Modules\AddOnFeature\Http\Controllers;

use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use Hexters\Ladmin\Exceptions\LadminException;

use Modules\AddOnFeature\Repositories\AddOnFeatureRepository;
use Modules\AddOnFeature\Entities\AddOnFeatureDatatables;
use App\Services\AddOnFeatureService;

class AddOnFeatureController extends Controller
{
protected $repository;
protected $service;

public function __construct(AddOnFeatureRepository $repository, AddOnFeatureService $service) {
$this->repository = $repository;
$this->service = $service;
}
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index()
{
ladmin()->allow('administrator.master-data.add-on-feature.index');

return AddOnFeatureDatatables::view('addonfeature::index');
}

/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('addonfeature::create');
}

/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
//
}

/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
return view('addonfeature::show');
}

/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('addonfeature::edit');
}

/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
}
Empty file.
Empty file.
Empty file.
126 changes: 126 additions & 0 deletions Modules/AddOnFeature/Providers/AddOnFeatureServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace Modules\AddOnFeature\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Hexters\Ladmin\Contracts\MasterRepositoryInterface;
use Modules\AddOnFeature\Repositories\AddOnFeatureRepository;

class AddOnFeatureServiceProvider extends ServiceProvider
{
/**
* @var string $moduleName
*/
protected $moduleName = 'AddOnFeature';

/**
* @var string $moduleNameLower
*/
protected $moduleNameLower = 'addonfeature';

/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}

/**
* Register repository patterb.
*
* @return void
*/
public function registerRepository()
{
$this->app->bind(
MasterRepositoryInterface::class,
AddOnFeatureRepository::class);
}

/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
], 'config');
$this->mergeConfigFrom(
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
);
}

/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);

$sourcePath = module_path($this->moduleName, 'Resources/views');

$this->publishes([
$sourcePath => $viewPath
], ['views', $this->moduleNameLower . '-module-views']);

$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}

/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);

if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
}
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}

private function getPublishableViewPaths(): array
{
$paths = [];
foreach (\Config::get('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}
return $paths;
}
}
69 changes: 69 additions & 0 deletions Modules/AddOnFeature/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Modules\AddOnFeature\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* The module namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $moduleNamespace = 'Modules\AddOnFeature\Http\Controllers';

/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{
parent::boot();
}

/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();

$this->mapWebRoutes();
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(module_path('AddOnFeature', '/Routes/web.php'));
}

/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(module_path('AddOnFeature', '/Routes/api.php'));
}
}
Loading