■ composer create-project laravel/laravel yes2 --prefer-dist 6.0
■ nova 폴더복사
■ .gitignore 파일에 nova 추가
■ composer.json 아래 추가
"repositories":[
{
"type": "path",
"url": "./nova"
}
],
"laravel/nova":"*"
■ composer update
■ php artisan nova:install
■ .env 파일을 열어서 데이터베이스 계정을 입력해준다.
■ php artisan migrate
■ config/app.php 에 아래 추가
App\Providers\NovaServiceProvider::class,
■ php artisan nova:user
■ php artisan make:migration create_posts_table --create=posts
■
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('body');
$table->timestamps();
});
}
■ php artisan make:model Post
■ php artisan migrate
■ php artisan nova:resource Post
■
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Trix;
■
Text::make('Title')->sortable(),
Trix::make('Body')->sortable(),
=========================================================================
https://laravelpackages.net/pktharindu/nova-permissions
■composer require pktharindu/nova-permissions
■php artisan vendor:publish --provider="Pktharindu\NovaPermissions\ToolServiceProvider" --tag="migrations"
■php artisan migrate
■php artisan vendor:publish --provider="Pktharindu\NovaPermissions\ToolServiceProvider" --tag="config"
■ in app/Providers/NovaServiceProvider.php
public function tools()
{
return [
// ...
new \Pktharindu\NovaPermissions\NovaPermissions(),
];
}
■ in app/Providers/AuthServiceProvider.php
use Illuminate\Support\Facades\Gate;
use Pktharindu\NovaPermissions\Traits\ValidatesPermissions;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
use ValidatesPermissions;
// ...
public function boot()
{
$this->registerPolicies();
foreach (config('nova-permissions.permissions') as $key => $permissions) {
Gate::define($key, function (User $user) use ($key) {
if ($this->nobodyHasAccess($key)) {
return true;
}
return $user->hasPermissionTo($key);
});
}
}
}
■ in app/User.php
use Illuminate\Notifications\Notifiable;
use Pktharindu\NovaPermissions\Traits\HasRoles;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasRoles,
Notifiable;
// ...
}
■use Laravel\Nova\Fields\BelongsToMany;
public function fields(Request $request)
{
return [
// ...
BelongsToMany::make('Roles', 'roles', \Pktharindu\NovaPermissions\Nova\Role::class),
];
}
'라라벨 > NOVA' 카테고리의 다른 글
nova 좌측메뉴 순서바꾸기 (0) | 2020.01.11 |
---|---|
nova 글 작성 유저 삽입하기 (0) | 2020.01.10 |
(package) nova Actions excel export(엑셀 추출) (0) | 2020.01.07 |
라라벨 설치부터 노바 미디어라이브러리 설치 (0) | 2020.01.06 |
windows에서 nova 404뜰때 (0) | 2020.01.06 |