Skip to content

Commit

Permalink
Merge pull request #53 from crynobone/nova5
Browse files Browse the repository at this point in the history
Nova 5 Integration
  • Loading branch information
leandrogehlen authored Dec 26, 2024
2 parents 22685aa + fee7d23 commit 199fb1c
Show file tree
Hide file tree
Showing 25 changed files with 566 additions and 74 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* text=auto

# Ignore following folder/file.
/.github export-ignore
/tests export-ignore
/workbench export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/testbench.yaml export-ignore
32 changes: 28 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,31 @@
}
],
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"require": {
"php": "^8.1",
"laravel/nova": "^5.0",
"spatie/laravel-permission": "^6.0"
},
"require-dev": {
"laravel/nova-devtool": "^1.2"
},
"autoload": {
"psr-4": {
"Sereny\\NovaPermissions\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"extra": {
"laravel": {
"providers": [
Expand All @@ -43,5 +53,19 @@
},
"config": {
"sort-packages": true
},
"scripts": {
"post-autoload-dump": [
"@clear",
"@prepare"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@build",
"@php vendor/bin/testbench serve --ansi"
]
}
}
3 changes: 1 addition & 2 deletions dist/js/tool.js

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions dist/js/tool.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/

/*!
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/**
* @license
* Lodash <https://lodash.com/>
Expand Down
33 changes: 0 additions & 33 deletions nova.mix.js

This file was deleted.

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
"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"
"production": "mix --production"
},
"devDependencies": {
"@inertiajs/inertia": "^0.11.1",
"@vue/babel-plugin-jsx": "^1.2.5",
"@vue/compiler-sfc": "^3.5.13",
"axios": "^1.7.9",
"laravel-mix": "^6.0.49",
"laravel-nova-devtool": "file:vendor/laravel/nova-devtool",
"vue-loader": "^16.8.3"
},
"dependencies": {
"lodash": "^4.17.21",
"postcss": "^8.4.49",
"vue-loader": "^17.4.2",
"vuex": "^4.1.0"
"vue": "^3.5.13"
}
}
11 changes: 6 additions & 5 deletions resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
{{ __(group) }}
</h1>
<div class="grid grid-cols-4 gap-4">
<div v-for="(permission, option) in permissions" :key="option">
<div v-for="(permission, option) in permissions" :key="option" class="flex items-center">
<Icon
viewBox="0 0 24 24"
width="24"
height="24"
:type="hasPermission(permission.option) ? 'check-circle' : 'x-circle'"
:name="hasPermission(permission.option) ? 'check-circle' : 'x-circle'"
:class="hasPermission(permission.option) ? 'text-green-500' : 'text-red-500'"
class="inline-block"
/>
<span class="ml-1">{{ permission.label }}</span>
</div>
Expand All @@ -25,7 +23,10 @@
</template>

<script>
import { Icon } from 'laravel-nova-ui';
export default {
components: { Icon },
props: [
'resource',
'resourceName',
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</template>

<script>
import { flatMap } from 'lodash';
import flatMap from 'lodash/flatMap';
export default {
props: [
Expand Down
3 changes: 1 addition & 2 deletions src/NovaPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public function boot()
Gate::policy(config('permission.models.permission'), $this->permissionPolicy);
Gate::policy(config('permission.models.role'), $this->rolePolicy);

Nova::script('nova-permissions', __DIR__.'/../dist/js/tool.js');
Nova::style('nova-permissions', __DIR__.'/../dist/css/tool.css');
Nova::mix('nova-permissions', __DIR__.'/../dist/mix-manifest.json');
}

/**
Expand Down
33 changes: 33 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
laravel: '@testbench'

providers:
- Laravel\Nova\NovaServiceProvider
- Laravel\Nova\NovaCoreServiceProvider
- Workbench\App\Providers\NovaServiceProvider
- Spatie\Permission\PermissionServiceProvider
- Sereny\NovaPermissions\ToolServiceProvider
# - Workbench\App\Providers\WorkbenchServiceProvider

migrations: true

seeders:
- Workbench\Database\Seeders\DatabaseSeeder
- Workbench\Database\Seeders\RolesAndPermissionsSeeder

workbench:
start: /nova
build:
- package:discover
- asset-publish
- create-sqlite-db
- db:wipe
- migrate:refresh
assets:
- migrations
- nova-assets
sync: []

purge:
directories:
- lang/*
- public/vendor/*
3 changes: 1 addition & 2 deletions webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
let mix = require('laravel-mix')

require('./nova.mix')
mix.extend('nova', new require('laravel-nova-devtool'))

mix
.setPublicPath('dist')
Expand Down
54 changes: 54 additions & 0 deletions workbench/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Workbench\App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
use HasFactory, HasRoles, Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

/**
* Determine if user is super admin.
*/
public function isSuperAdmin(): bool
{
return in_array($this->email, ['nova@laravel.com']);
}
}
45 changes: 45 additions & 0 deletions workbench/app/Nova/Resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Workbench\App\Nova;

use Illuminate\Contracts\Database\Eloquent\Builder;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource as NovaResource;
use Laravel\Scout\Builder as ScoutBuilder;

abstract class Resource extends NovaResource
{
/**
* Build an "index" query for the given resource.
*/
public static function indexQuery(NovaRequest $request, Builder $query): Builder
{
return $query;
}

/**
* Build a Scout search query for the given resource.
*/
public static function scoutQuery(NovaRequest $request, ScoutBuilder $query): ScoutBuilder
{
return $query;
}

/**
* Build a "detail" query for the given resource.
*/
public static function detailQuery(NovaRequest $request, Builder $query): Builder
{
return parent::detailQuery($request, $query);
}

/**
* Build a "relatable" query for the given resource.
*
* This query determines which instances of the model may be attached to other resources.
*/
public static function relatableQuery(NovaRequest $request, Builder $query): Builder
{
return parent::relatableQuery($request, $query);
}
}
Loading

0 comments on commit 199fb1c

Please sign in to comment.