Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 26, 2024
1 parent 22685aa commit 44d9bb9
Show file tree
Hide file tree
Showing 18 changed files with 478 additions and 50 deletions.
41 changes: 35 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "sereny/nova-permissions",
"description": "Laravel Nova - Roles & Permissions",
"keywords": [ "laravel", "nova", "permission", "role" ],
"keywords": [
"laravel",
"nova",
"permission",
"role"
],
"license": "MIT",
"prefer-stable": true,
"support": {
Expand All @@ -16,16 +21,19 @@
}
],
"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/"
Expand All @@ -43,5 +51,26 @@
},
"config": {
"sort-packages": true
},
"autoload-dev": {
"psr-4": {
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"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"
]
}
}
}
33 changes: 0 additions & 33 deletions nova.mix.js

This file was deleted.

11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
"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",
"lodash": "^4.17.21",
"postcss": "^8.4.49",
"vue-loader": "^17.4.2",
"vuex": "^4.1.0"
"laravel-nova-devtool": "file:vendor/laravel/nova-devtool"
}
}
29 changes: 29 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
laravel: '@testbench'

providers:
- Laravel\Nova\NovaServiceProvider
- Laravel\Nova\NovaCoreServiceProvider
- Workbench\App\Providers\NovaServiceProvider
# - Workbench\App\Providers\WorkbenchServiceProvider

migrations: true

seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
start: /nova
build:
- package:discover
- asset-publish
- create-sqlite-db
- db:wipe
- migrate:refresh
assets:
- 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
45 changes: 45 additions & 0 deletions workbench/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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;

class User extends Authenticatable
{
use HasFactory, 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',
];
}
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);
}
}
105 changes: 105 additions & 0 deletions workbench/app/Nova/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace Workbench\App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Auth\PasswordValidationRules;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Password;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class User extends Resource
{
use PasswordValidationRules;

/**
* The model the resource corresponds to.
*
* @var class-string<\Workbench\App\Models\User>
*/
public static $model = \Workbench\App\Models\User::class;

/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';

/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id', 'name', 'email',
];

/**
* Get the fields displayed by the resource.
*
* @return array<int, \Laravel\Nova\Fields\Field|\Laravel\Nova\Panel|\Laravel\Nova\ResourceTool|\Illuminate\Http\Resources\MergeValue>
*/
public function fields(NovaRequest $request): array
{
return [
ID::make()->sortable(),

Text::make('Name')
->sortable()
->rules('required', 'max:255'),

Text::make('Email')
->sortable()
->rules('required', 'email', 'max:254')
->creationRules('unique:users,email')
->updateRules('unique:users,email,{{resourceId}}'),

Password::make('Password')
->onlyOnForms()
->creationRules($this->passwordRules())
->updateRules($this->optionalPasswordRules()),
];
}

/**
* Get the cards available for the request.
*
* @return array<int, \Laravel\Nova\Card>
*/
public function cards(NovaRequest $request): array
{
return [];
}

/**
* Get the filters available for the resource.
*
* @return array<int, \Laravel\Nova\Filters\Filter>
*/
public function filters(NovaRequest $request): array
{
return [];
}

/**
* Get the lenses available for the resource.
*
* @return array<int, \Laravel\Nova\Lenses\Lens>
*/
public function lenses(NovaRequest $request): array
{
return [];
}

/**
* Get the actions available for the resource.
*
* @return array<int, \Laravel\Nova\Actions\Action>
*/
public function actions(NovaRequest $request): array
{
return [];
}
}
Loading

0 comments on commit 44d9bb9

Please sign in to comment.