First setup: module registry, switchable modules, permissions
This commit is contained in:
commit
936c794597
52 files changed
+1304
No files matched your search
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Reviews;
|
||||
|
||||
use IriksIT\Manager\Models\Review;
|
||||
|
||||
class ReviewsController
|
||||
{
|
||||
/** First opzet: lists the records as JSON. The screens come with the frontend. */
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Review::query()->latest()->paginate(25));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Reviews;
|
||||
|
||||
use IriksIT\Manager\Modules\BaseModule;
|
||||
|
||||
class ReviewsModule extends BaseModule
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'reviews';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Reviews';
|
||||
}
|
||||
|
||||
public function enabledByDefault(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return [
|
||||
'reviews.manage' => 'Manage the reviews',
|
||||
];
|
||||
}
|
||||
|
||||
public function navigation(): array
|
||||
{
|
||||
return [
|
||||
['label' => 'Reviews', 'route' => 'manager.reviews.index', 'permission' => 'reviews.manage'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('manager.table_prefix').'reviews', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('author');
|
||||
$table->string('place')->nullable();
|
||||
$table->unsignedTinyInteger('rating')->nullable();
|
||||
$table->text('body');
|
||||
$table->boolean('is_visible')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('manager.table_prefix').'reviews');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use IriksIT\Manager\Modules\Reviews\ReviewsController;
|
||||
|
||||
Route::get('/reviews', [ReviewsController::class, 'index'])->name('reviews.index')->middleware('can:reviews.manage');
|
||||
Reference in new issue
Block a user