#127 Implement Resource Lock

This commit is contained in:
Nisse Lommerde 2025-04-03 16:27:46 -04:00
parent 63d5f427ad
commit 86e48f8e16
7 changed files with 112 additions and 8 deletions

View File

@ -21,9 +21,12 @@
use Filament\Resources\Pages\EditRecord;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Model;
use Kenepa\ResourceLock\Resources\Pages\Concerns\UsesResourceLock;
class EditOrder extends EditRecord
{
use UsesResourceLock;
protected static string $resource = OrderResource::class;
public function getTitle(): string|Htmlable

View File

@ -16,13 +16,14 @@
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Kenepa\ResourceLock\Models\Concerns\HasLocks;
#[ObservedBy(OrderObserver::class)]
class Order extends Model
{
/** @use HasFactory<OrderFactory> */
use HasFactory, SoftDeletes;
use HasFactory, SoftDeletes, HasLocks;
protected $fillable = [
'customer_id',

View File

@ -18,6 +18,7 @@
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Kenepa\ResourceLock\ResourceLockPlugin;
class AdminPanelProvider extends PanelProvider
{
@ -62,6 +63,7 @@ public function panel(Panel $panel): Panel
NavigationGroup::make('Financial'),
NavigationGroup::make('Reports'),
NavigationGroup::make('Settings'),
]);
])
->plugin(ResourceLockPlugin::make());
}
}

View File

@ -7,15 +7,16 @@
"require": {
"php": "^8.2",
"davidhsianturi/blade-bootstrap-icons": "^1.5",
"fakerphp/faker": "^1.23",
"filament/filament": "^3.2",
"guava/filament-clusters": "^1.4",
"icetalker/filament-table-repeater": "^1.3",
"kenepa/resource-lock": "^2.1",
"laravel/framework": "^11.9",
"laravel/tinker": "^2.9",
"livewire/livewire": "^3.5",
"mallardduck/blade-lucide-icons": "^1.23",
"spatie/laravel-pdf": "^1.5",
"fakerphp/faker": "^1.23"
"spatie/laravel-pdf": "^1.5"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.5",

74
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "46ac06345fc3d57a7d0a01cfcaeaac17",
"content-hash": "8b981a2679ca20ca011a3c8b0c38ec22",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@ -2238,6 +2238,74 @@
],
"time": "2025-03-05T16:06:45+00:00"
},
{
"name": "kenepa/resource-lock",
"version": "2.1.3",
"source": {
"type": "git",
"url": "https://github.com/kenepa/resource-lock.git",
"reference": "dda6e14b5c4a47817569081b11248c572ebdfd07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kenepa/resource-lock/zipball/dda6e14b5c4a47817569081b11248c572ebdfd07",
"reference": "dda6e14b5c4a47817569081b11248c572ebdfd07",
"shasum": ""
},
"require": {
"filament/filament": "^3.0",
"illuminate/contracts": "^9.0|^10.0|^11.0|^12.0",
"php": "^8.1",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0|^8.1",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
"pestphp/pest": "^2.0|^3.7",
"pestphp/pest-plugin-laravel": "^2.0|^3.1",
"pestphp/pest-plugin-livewire": "^2.0|^3.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
"phpstan/phpstan-phpunit": "^1.0|^2.0",
"spatie/laravel-ray": "^1.26",
"tightenco/duster": "^1.1|^3.1"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"ResourceLock": "Kenepa\\ResourceLock\\Facades\\ResourceLock"
},
"providers": [
"Kenepa\\ResourceLock\\ResourceLockServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Kenepa\\ResourceLock\\": "src",
"Kenepa\\ResourceLock\\Database\\Factories\\": "database/factories"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Filament Resource Lock is a Filament plugin that adds resource locking functionality to your site.",
"homepage": "https://github.com/kenepa/resource-lock",
"keywords": [
"Kenepa",
"laravel",
"resource-lock"
],
"support": {
"issues": "https://github.com/kenepa/resource-lock/issues",
"source": "https://github.com/kenepa/resource-lock/tree/2.1.3"
},
"time": "2025-03-14T16:31:20+00:00"
},
{
"name": "kirschbaum-development/eloquent-power-joins",
"version": "4.2.1",
@ -11705,12 +11773,12 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.2"
},
"platform-dev": {},
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('resource_locks', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->foreignId('user_id')->constrained();
$table->morphs('lockable');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('resource_locks');
}
};

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "topnotch_website",
"name": "order_system",
"lockfileVersion": 3,
"requires": true,
"packages": {