This commit is contained in:
2024-09-01 18:54:23 +05:00
parent 76d18365a5
commit 061f09eca1
1597 changed files with 109451 additions and 1 deletions

10
nova/src/Console/tool-stubs/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
/.idea
/vendor
/node_modules
package-lock.json
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
Thumbs.db

View File

@@ -0,0 +1,29 @@
{
"name": "{{ name }}",
"description": "A Laravel Nova tool.",
"keywords": [
"laravel",
"nova"
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0"
},
"autoload": {
"psr-4": {
"{{ escapedNamespace }}\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"{{ escapedNamespace }}\\ToolServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@@ -0,0 +1,33 @@
const mix = require('laravel-mix')
const webpack = require('webpack')
const path = require('path')
class NovaExtension {
name() {
return 'nova-extension'
}
register(name) {
this.name = name
}
webpackConfig(webpackConfig) {
webpackConfig.externals = {
vue: 'Vue',
}
webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias || {}),
'laravel-nova': path.join(
__dirname,
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
),
}
webpackConfig.output = {
uniqueName: this.name,
}
}
}
mix.extend('nova', new NovaExtension())

View File

@@ -0,0 +1,20 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.2.22",
"laravel-mix": "^6.0.41",
"postcss": "^8.3.11",
"vue-loader": "^16.8.3"
},
"dependencies": {}
}

View File

@@ -0,0 +1 @@
module.exports = {}

View File

@@ -0,0 +1 @@
/* Nova Tool CSS */

View File

@@ -0,0 +1,50 @@
<template>
<div>
<Head title="{{ title }}" />
<Heading class="mb-6">{{ title }}</Heading>
<Card
class="flex flex-col items-center justify-center"
style="min-height: 300px"
>
<svg
class="animate-spin fill-80 mb-6"
width="69"
height="72"
viewBox="0 0 23 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.12 20.455A12.184 12.184 0 0 1 11.5 24a12.18 12.18 0 0 1-9.333-4.319c4.772 3.933 11.88 3.687 16.36-.738a7.571 7.571 0 0 0 0-10.8c-3.018-2.982-7.912-2.982-10.931 0a3.245 3.245 0 0 0 0 4.628 3.342 3.342 0 0 0 4.685 0 1.114 1.114 0 0 1 1.561 0 1.082 1.082 0 0 1 0 1.543 5.57 5.57 0 0 1-7.808 0 5.408 5.408 0 0 1 0-7.714c3.881-3.834 10.174-3.834 14.055 0a9.734 9.734 0 0 1 .03 13.855zM4.472 5.057a7.571 7.571 0 0 0 0 10.8c3.018 2.982 7.912 2.982 10.931 0a3.245 3.245 0 0 0 0-4.628 3.342 3.342 0 0 0-4.685 0 1.114 1.114 0 0 1-1.561 0 1.082 1.082 0 0 1 0-1.543 5.57 5.57 0 0 1 7.808 0 5.408 5.408 0 0 1 0 7.714c-3.881 3.834-10.174 3.834-14.055 0a9.734 9.734 0 0 1-.015-13.87C5.096 1.35 8.138 0 11.5 0c3.75 0 7.105 1.68 9.333 4.319C16.06.386 8.953.632 4.473 5.057z"
fill-rule="evenodd"
/>
</svg>
<h1 class="dark:text-white text-4xl font-light mb-6">
We're in a black hole.
</h1>
<p class="dark:text-white text-lg opacity-70">
You can edit this tool's component at:
<code
class="ml-1 border border-gray-100 dark:border-gray-900 text-sm font-mono text-white bg-black rounded px-2 py-1"
>
/nova-components/{{ class }}/resources/js/pages/Tool.vue
</code>
</p>
</Card>
</div>
</template>
<script>
export default {
mounted() {
//
},
}
</script>
<style>
/* Scoped Styles */
</style>

View File

@@ -0,0 +1,5 @@
import Tool from './pages/Tool'
Nova.booting((app, store) => {
Nova.inertia('{{ class }}', Tool)
})

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Tool API Routes
|--------------------------------------------------------------------------
|
| Here is where you may register API routes for your tool. These routes
| are loaded by the ServiceProvider of your tool. They are protected
| by your tool's "Authorize" middleware by default. Now, go build!
|
*/
// Route::get('/', function (Request $request) {
// //
// });

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Support\Facades\Route;
use Laravel\Nova\Http\Requests\NovaRequest;
/*
|--------------------------------------------------------------------------
| Tool Routes
|--------------------------------------------------------------------------
|
| Here is where you may register Inertia routes for your tool. These are
| loaded by the ServiceProvider of the tool. The routes are protected
| by your tool's "Authorize" middleware by default. Now - go build!
|
*/
Route::get('/', function (NovaRequest $request) {
return inertia('{{ class }}');
});

View File

@@ -0,0 +1,34 @@
<?php
namespace {{ namespace }}\Http\Middleware;
use Laravel\Nova\Nova;
use {{ namespace }}\{{ class }};
class Authorize
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request):mixed $next
* @return \Illuminate\Http\Response
*/
public function handle($request, $next)
{
$tool = collect(Nova::registeredTools())->first([$this, 'matchesTool']);
return optional($tool)->authorize($request) ? $next($request) : abort(403);
}
/**
* Determine whether this tool belongs to the package.
*
* @param \Laravel\Nova\Tool $tool
* @return bool
*/
public function matchesTool($tool)
{
return $tool instanceof {{ class }};
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace {{ namespace }};
use Illuminate\Http\Request;
use Laravel\Nova\Menu\MenuSection;
use Laravel\Nova\Nova;
use Laravel\Nova\Tool;
class {{ class }} extends Tool
{
/**
* Perform any tasks that need to happen when the tool is booted.
*
* @return void
*/
public function boot()
{
Nova::script('{{ component }}', __DIR__.'/../dist/js/tool.js');
Nova::style('{{ component }}', __DIR__.'/../dist/css/tool.css');
}
/**
* Build the menu that renders the navigation links for the tool.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function menu(Request $request)
{
return MenuSection::make('{{ title }}')
->path('/{{ name }}')
->icon('server');
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace {{ namespace }};
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Http\Middleware\Authenticate;
use Laravel\Nova\Nova;
use {{ namespace }}\Http\Middleware\Authorize;
class ToolServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app->booted(function () {
$this->routes();
});
Nova::serving(function (ServingNova $event) {
//
});
}
/**
* Register the tool's routes.
*
* @return void
*/
protected function routes()
{
if ($this->app->routesAreCached()) {
return;
}
Nova::router(['nova', Authenticate::class, Authorize::class], '{{ name }}')
->group(__DIR__.'/../routes/inertia.php');
Route::middleware(['nova', Authorize::class])
->prefix('nova-vendor/{{ name }}')
->group(__DIR__.'/../routes/api.php');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@@ -0,0 +1,10 @@
let mix = require('laravel-mix')
require('./nova.mix')
mix
.setPublicPath('dist')
.js('resources/js/tool.js', 'js')
.vue({ version: 3 })
.css('resources/css/tool.css', 'css')
.nova('{{ name }}')