mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
- 2.x - scripts
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
use App\Helpers\HtmxResponse;
|
||||
use Filament\Notifications\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
function generate_public_key($privateKeyPath, $publicKeyPath): void
|
||||
{
|
||||
@ -146,3 +148,22 @@ function tail($filepath, $lines = 1, $adaptive = true): string
|
||||
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
function get_from_route(string $modelName, string $routeKey): mixed
|
||||
{
|
||||
$model = request()->route($routeKey);
|
||||
|
||||
if (! $model) {
|
||||
$model = Route::getRoutes()->match(Request::create(url()->previous()))->parameter($routeKey);
|
||||
}
|
||||
|
||||
if ($model instanceof $modelName) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
if ($model) {
|
||||
return $modelName::query()->find($model);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user