Browse Source

Voyager + routes

master
Le Libre Au Quotidien 3 months ago
parent
commit
d7dd55c19f
19 changed files with 2810 additions and 40 deletions
  1. +1
    -1
      app/Models/User.php
  2. +9
    -2
      composer.json
  3. +1358
    -34
      composer.lock
  4. +7
    -0
      config/hooks.php
  5. +12
    -0
      config/voyager-hooks.php
  6. +260
    -0
      config/voyager.php
  7. +370
    -0
      database/seeds/DataRowsTableSeeder.php
  8. +69
    -0
      database/seeds/DataTypesTableSeeder.php
  9. +177
    -0
      database/seeds/MenuItemsTableSeeder.php
  10. +19
    -0
      database/seeds/MenusTableSeeder.php
  11. +24
    -0
      database/seeds/PermissionRoleTableSeeder.php
  12. +36
    -0
      database/seeds/PermissionsTableSeeder.php
  13. +27
    -0
      database/seeds/RolesTableSeeder.php
  14. +145
    -0
      database/seeds/SettingsTableSeeder.php
  15. +231
    -0
      database/seeds/TranslationsTableSeeder.php
  16. +28
    -0
      database/seeds/VoyagerDatabaseSeeder.php
  17. +27
    -0
      database/seeds/VoyagerDummyDatabaseSeeder.php
  18. +1
    -0
      hooks/hooks.json
  19. +9
    -3
      routes/web.php

+ 1
- 1
app/Models/User.php View File

@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
class User extends \TCG\Voyager\Models\User
{
use HasFactory, Notifiable;

+ 9
- 2
composer.json View File

@ -13,7 +13,8 @@
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0"
"laravel/tinker": "^2.0",
"tcg/voyager": "^1.4"
},
"require-dev": {
"facade/ignition": "^2.3.6",
@ -57,5 +58,11 @@
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"repositories": {
"hooks": {
"type": "composer",
"url": "https://larapack.io"
}
}
}
}

+ 1358
- 34
composer.lock
File diff suppressed because it is too large
View File


+ 7
- 0
config/hooks.php View File

@ -0,0 +1,7 @@
<?php
return [
'enabled' => env('HOOKS_ENABLED', true),
];

+ 12
- 0
config/voyager-hooks.php View File

@ -0,0 +1,12 @@
<?php
return [
'enabled' => env('HOOKS_ENABLED', true),
'add-route' => true,
'add-hook-menu-item' => true,
'add-hook-permissions' => true,
'publish-vendor-files' => true,
];

+ 260
- 0
config/voyager.php View File

@ -0,0 +1,260 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| User config
|--------------------------------------------------------------------------
|
| Here you can specify voyager user configs
|
*/
'user' => [
'add_default_role_on_register' => true,
'default_role' => 'user',
'default_avatar' => 'users/default.png',
'redirect' => '/admin',
],
/*
|--------------------------------------------------------------------------
| Controllers config
|--------------------------------------------------------------------------
|
| Here you can specify voyager controller settings
|
*/
'controllers' => [
'namespace' => 'TCG\\Voyager\\Http\\Controllers',
],
/*
|--------------------------------------------------------------------------
| Models config
|--------------------------------------------------------------------------
|
| Here you can specify default model namespace when creating BREAD.
| Must include trailing backslashes. If not defined the default application
| namespace will be used.
|
*/
'models' => [
//'namespace' => 'App\\',
],
/*
|--------------------------------------------------------------------------
| Storage Config
|--------------------------------------------------------------------------
|
| Here you can specify attributes related to your application file system
|
*/
'storage' => [
'disk' => env('FILESYSTEM_DRIVER', 'public'),
],
/*
|--------------------------------------------------------------------------
| Media Manager
|--------------------------------------------------------------------------
|
| Here you can specify if media manager can show hidden files like(.gitignore)
|
*/
'hidden_files' => false,
/*
|--------------------------------------------------------------------------
| Database Config
|--------------------------------------------------------------------------
|
| Here you can specify voyager database settings
|
*/
'database' => [
'tables' => [
'hidden' => ['migrations', 'data_rows', 'data_types', 'menu_items', 'password_resets', 'permission_role', 'settings'],
],
'autoload_migrations' => true,
],
/*
|--------------------------------------------------------------------------
| Multilingual configuration
|--------------------------------------------------------------------------
|
| Here you can specify if you want Voyager to ship with support for
| multilingual and what locales are enabled.
|
*/
'multilingual' => [
/*
* Set whether or not the multilingual is supported by the BREAD input.
*/
'enabled' => false,
/*
* Select default language
*/
'default' => 'en',
/*
* Select languages that are supported.
*/
'locales' => [
'en',
//'pt',
],
],
/*
|--------------------------------------------------------------------------
| Dashboard config
|--------------------------------------------------------------------------
|
| Here you can modify some aspects of your dashboard
|
*/
'dashboard' => [
// Add custom list items to navbar's dropdown
'navbar_items' => [
'voyager::generic.profile' => [
'route' => 'voyager.profile',
'classes' => 'class-full-of-rum',
'icon_class' => 'voyager-person',
],
'voyager::generic.home' => [
'route' => '/',
'icon_class' => 'voyager-home',
'target_blank' => true,
],
'voyager::generic.logout' => [
'route' => 'voyager.logout',
'icon_class' => 'voyager-power',
],
],
'widgets' => [
],
],
/*
|--------------------------------------------------------------------------
| Automatic Procedures
|--------------------------------------------------------------------------
|
| When a change happens on Voyager, we can automate some routines.
|
*/
'bread' => [
// When a BREAD is added, create the Menu item using the BREAD properties.
'add_menu_item' => true,
// which menu add item to
'default_menu' => 'admin',
// When a BREAD is added, create the related Permission.
'add_permission' => true,
// which role add premissions to
'default_role' => 'admin',
],
/*
|--------------------------------------------------------------------------
| UI Generic Config
|--------------------------------------------------------------------------
|
| Here you change some of the Voyager UI settings.
|
*/
'primary_color' => '#22A7F0',
'show_dev_tips' => true, // Show development tip "How To Use:" in Menu and Settings
// Here you can specify additional assets you would like to be included in the master.blade
'additional_css' => [
//'css/custom.css',
],
'additional_js' => [
//'js/custom.js',
],
'googlemaps' => [
'key' => env('GOOGLE_MAPS_KEY', ''),
'center' => [
'lat' => env('GOOGLE_MAPS_DEFAULT_CENTER_LAT', '32.715738'),
'lng' => env('GOOGLE_MAPS_DEFAULT_CENTER_LNG', '-117.161084'),
],
'zoom' => env('GOOGLE_MAPS_DEFAULT_ZOOM', 11),
],
/*
|--------------------------------------------------------------------------
| Model specific settings
|--------------------------------------------------------------------------
|
| Here you change some model specific settings
|
*/
'settings' => [
// Enables Laravel cache method for
// storing cache values between requests
'cache' => false,
],
// Activate compass when environment is NOT local
'compass_in_production' => false,
'media' => [
// The allowed mimetypes to be uploaded through the media-manager.
'allowed_mimetypes' => '*', //All types can be uploaded
/*
'allowed_mimetypes' => [
'image/jpeg',
'image/png',
'image/gif',
'image/bmp',
'video/mp4',
],
*/
//Path for media-manager. Relative to the filesystem.
'path' => '/',
'show_folders' => true,
'allow_upload' => true,
'allow_move' => true,
'allow_delete' => true,
'allow_create_folder' => true,
'allow_rename' => true,
/*'watermark' => [
'source' => 'watermark.png',
'position' => 'bottom-left',
'x' => 0,
'y' => 0,
'size' => 15,
],
'thumbnails' => [
[
'type' => 'fit',
'name' => 'fit-500',
'width' => 500,
'height'=> 500
],
]*/
],
];

+ 370
- 0
database/seeds/DataRowsTableSeeder.php View File

@ -0,0 +1,370 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataRow;
use TCG\Voyager\Models\DataType;
class DataRowsTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*/
public function run()
{
$userDataType = DataType::where('slug', 'users')->firstOrFail();
$menuDataType = DataType::where('slug', 'menus')->firstOrFail();
$roleDataType = DataType::where('slug', 'roles')->firstOrFail();
$dataRow = $this->dataRow($userDataType, 'id');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'number',
'display_name' => __('voyager::seeders.data_rows.id'),
'required' => 1,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 1,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'name');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.name'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 2,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'email');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.email'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 3,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'password');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'password',
'display_name' => __('voyager::seeders.data_rows.password'),
'required' => 1,
'browse' => 0,
'read' => 0,
'edit' => 1,
'add' => 1,
'delete' => 0,
'order' => 4,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'remember_token');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.remember_token'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 5,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'created_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.created_at'),
'required' => 0,
'browse' => 1,
'read' => 1,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 6,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'updated_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.updated_at'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 7,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'avatar');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'image',
'display_name' => __('voyager::seeders.data_rows.avatar'),
'required' => 0,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 8,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'user_belongsto_role_relationship');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'relationship',
'display_name' => __('voyager::seeders.data_rows.role'),
'required' => 0,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 0,
'details' => [
'model' => 'TCG\\Voyager\\Models\\Role',
'table' => 'roles',
'type' => 'belongsTo',
'column' => 'role_id',
'key' => 'id',
'label' => 'display_name',
'pivot_table' => 'roles',
'pivot' => 0,
],
'order' => 10,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'user_belongstomany_role_relationship');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'relationship',
'display_name' => 'Roles',
'required' => 0,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 0,
'details' => [
'model' => 'TCG\\Voyager\\Models\\Role',
'table' => 'roles',
'type' => 'belongsToMany',
'column' => 'id',
'key' => 'id',
'label' => 'display_name',
'pivot_table' => 'user_roles',
'pivot' => '1',
'taggable' => '0',
],
'order' => 11,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'settings');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'hidden',
'display_name' => 'Settings',
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 12,
])->save();
}
$dataRow = $this->dataRow($menuDataType, 'id');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'number',
'display_name' => __('voyager::seeders.data_rows.id'),
'required' => 1,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 1,
])->save();
}
$dataRow = $this->dataRow($menuDataType, 'name');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.name'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 2,
])->save();
}
$dataRow = $this->dataRow($menuDataType, 'created_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.created_at'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 3,
])->save();
}
$dataRow = $this->dataRow($menuDataType, 'updated_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.updated_at'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 4,
])->save();
}
$dataRow = $this->dataRow($roleDataType, 'id');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'number',
'display_name' => __('voyager::seeders.data_rows.id'),
'required' => 1,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 1,
])->save();
}
$dataRow = $this->dataRow($roleDataType, 'name');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.name'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 2,
])->save();
}
$dataRow = $this->dataRow($roleDataType, 'created_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.created_at'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 3,
])->save();
}
$dataRow = $this->dataRow($roleDataType, 'updated_at');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'timestamp',
'display_name' => __('voyager::seeders.data_rows.updated_at'),
'required' => 0,
'browse' => 0,
'read' => 0,
'edit' => 0,
'add' => 0,
'delete' => 0,
'order' => 4,
])->save();
}
$dataRow = $this->dataRow($roleDataType, 'display_name');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.display_name'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 5,
])->save();
}
$dataRow = $this->dataRow($userDataType, 'role_id');
if (!$dataRow->exists) {
$dataRow->fill([
'type' => 'text',
'display_name' => __('voyager::seeders.data_rows.role'),
'required' => 1,
'browse' => 1,
'read' => 1,
'edit' => 1,
'add' => 1,
'delete' => 1,
'order' => 9,
])->save();
}
}
/**
* [dataRow description].
*
* @param [type] $type [description]
* @param [type] $field [description]
*
* @return [type] [description]
*/
protected function dataRow($type, $field)
{
return DataRow::firstOrNew([
'data_type_id' => $type->id,
'field' => $field,
]);
}
}

+ 69
- 0
database/seeds/DataTypesTableSeeder.php View File

@ -0,0 +1,69 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\DataType;
class DataTypesTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*/
public function run()
{
$dataType = $this->dataType('slug', 'users');
if (!$dataType->exists) {
$dataType->fill([
'name' => 'users',
'display_name_singular' => __('voyager::seeders.data_types.user.singular'),
'display_name_plural' => __('voyager::seeders.data_types.user.plural'),
'icon' => 'voyager-person',
'model_name' => 'TCG\\Voyager\\Models\\User',
'policy_name' => 'TCG\\Voyager\\Policies\\UserPolicy',
'controller' => 'TCG\\Voyager\\Http\\Controllers\\VoyagerUserController',
'generate_permissions' => 1,
'description' => '',
])->save();
}
$dataType = $this->dataType('slug', 'menus');
if (!$dataType->exists) {
$dataType->fill([
'name' => 'menus',
'display_name_singular' => __('voyager::seeders.data_types.menu.singular'),
'display_name_plural' => __('voyager::seeders.data_types.menu.plural'),
'icon' => 'voyager-list',
'model_name' => 'TCG\\Voyager\\Models\\Menu',
'controller' => '',
'generate_permissions' => 1,
'description' => '',
])->save();
}
$dataType = $this->dataType('slug', 'roles');
if (!$dataType->exists) {
$dataType->fill([
'name' => 'roles',
'display_name_singular' => __('voyager::seeders.data_types.role.singular'),
'display_name_plural' => __('voyager::seeders.data_types.role.plural'),
'icon' => 'voyager-lock',
'model_name' => 'TCG\\Voyager\\Models\\Role',
'controller' => 'TCG\\Voyager\\Http\\Controllers\\VoyagerRoleController',
'generate_permissions' => 1,
'description' => '',
])->save();
}
}
/**
* [dataType description].
*
* @param [type] $field [description]
* @param [type] $for [description]
*
* @return [type] [description]
*/
protected function dataType($field, $for)
{
return DataType::firstOrNew([$field => $for]);
}
}

+ 177
- 0
database/seeds/MenuItemsTableSeeder.php View File

@ -0,0 +1,177 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Menu;
use TCG\Voyager\Models\MenuItem;
class MenuItemsTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*
* @return void
*/
public function run()
{
$menu = Menu::where('name', 'admin')->firstOrFail();
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.dashboard'),
'url' => '',
'route' => 'voyager.dashboard',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-boat',
'color' => null,
'parent_id' => null,
'order' => 1,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.media'),
'url' => '',
'route' => 'voyager.media.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-images',
'color' => null,
'parent_id' => null,
'order' => 5,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.users'),
'url' => '',
'route' => 'voyager.users.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-person',
'color' => null,
'parent_id' => null,
'order' => 3,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.roles'),
'url' => '',
'route' => 'voyager.roles.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-lock',
'color' => null,
'parent_id' => null,
'order' => 2,
])->save();
}
$toolsMenuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.tools'),
'url' => '',
]);
if (!$toolsMenuItem->exists) {
$toolsMenuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-tools',
'color' => null,
'parent_id' => null,
'order' => 9,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.menu_builder'),
'url' => '',
'route' => 'voyager.menus.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-list',
'color' => null,
'parent_id' => $toolsMenuItem->id,
'order' => 10,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.database'),
'url' => '',
'route' => 'voyager.database.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-data',
'color' => null,
'parent_id' => $toolsMenuItem->id,
'order' => 11,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.compass'),
'url' => '',
'route' => 'voyager.compass.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-compass',
'color' => null,
'parent_id' => $toolsMenuItem->id,
'order' => 12,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.bread'),
'url' => '',
'route' => 'voyager.bread.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-bread',
'color' => null,
'parent_id' => $toolsMenuItem->id,
'order' => 13,
])->save();
}
$menuItem = MenuItem::firstOrNew([
'menu_id' => $menu->id,
'title' => __('voyager::seeders.menu_items.settings'),
'url' => '',
'route' => 'voyager.settings.index',
]);
if (!$menuItem->exists) {
$menuItem->fill([
'target' => '_self',
'icon_class' => 'voyager-settings',
'color' => null,
'parent_id' => null,
'order' => 14,
])->save();
}
}
}

+ 19
- 0
database/seeds/MenusTableSeeder.php View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Menu;
class MenusTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*
* @return void
*/
public function run()
{
Menu::firstOrCreate([
'name' => 'admin',
]);
}
}

+ 24
- 0
database/seeds/PermissionRoleTableSeeder.php View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Permission;
use TCG\Voyager\Models\Role;
class PermissionRoleTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*
* @return void
*/
public function run()
{
$role = Role::where('name', 'admin')->firstOrFail();
$permissions = Permission::all();
$role->permissions()->sync(
$permissions->pluck('id')->all()
);
}
}

+ 36
- 0
database/seeds/PermissionsTableSeeder.php View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Permission;
class PermissionsTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*/
public function run()
{
$keys = [
'browse_admin',
'browse_bread',
'browse_database',
'browse_media',
'browse_compass',
];
foreach ($keys as $key) {
Permission::firstOrCreate([
'key' => $key,
'table_name' => null,
]);
}
Permission::generateFor('menus');
Permission::generateFor('roles');
Permission::generateFor('users');
Permission::generateFor('settings');
}
}

+ 27
- 0
database/seeds/RolesTableSeeder.php View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Role;
class RolesTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*/
public function run()
{
$role = Role::firstOrNew(['name' => 'admin']);
if (!$role->exists) {
$role->fill([
'display_name' => __('voyager::seeders.roles.admin'),
])->save();
}
$role = Role::firstOrNew(['name' => 'user']);
if (!$role->exists) {
$role->fill([
'display_name' => __('voyager::seeders.roles.user'),
])->save();
}
}
}

+ 145
- 0
database/seeds/SettingsTableSeeder.php View File

@ -0,0 +1,145 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Setting;
class SettingsTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*/
public function run()
{
$setting = $this->findSetting('site.title');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.site.title'),
'value' => __('voyager::seeders.settings.site.title'),
'details' => '',
'type' => 'text',
'order' => 1,
'group' => 'Site',
])->save();
}
$setting = $this->findSetting('site.description');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.site.description'),
'value' => __('voyager::seeders.settings.site.description'),
'details' => '',
'type' => 'text',
'order' => 2,
'group' => 'Site',
])->save();
}
$setting = $this->findSetting('site.logo');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.site.logo'),
'value' => '',
'details' => '',
'type' => 'image',
'order' => 3,
'group' => 'Site',
])->save();
}
$setting = $this->findSetting('site.google_analytics_tracking_id');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.site.google_analytics_tracking_id'),
'value' => '',
'details' => '',
'type' => 'text',
'order' => 4,
'group' => 'Site',
])->save();
}
$setting = $this->findSetting('admin.bg_image');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.background_image'),
'value' => '',
'details' => '',
'type' => 'image',
'order' => 5,
'group' => 'Admin',
])->save();
}
$setting = $this->findSetting('admin.title');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.title'),
'value' => 'Voyager',
'details' => '',
'type' => 'text',
'order' => 1,
'group' => 'Admin',
])->save();
}
$setting = $this->findSetting('admin.description');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.description'),
'value' => __('voyager::seeders.settings.admin.description_value'),
'details' => '',
'type' => 'text',
'order' => 2,
'group' => 'Admin',
])->save();
}
$setting = $this->findSetting('admin.loader');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.loader'),
'value' => '',
'details' => '',
'type' => 'image',
'order' => 3,
'group' => 'Admin',
])->save();
}
$setting = $this->findSetting('admin.icon_image');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.icon_image'),
'value' => '',
'details' => '',
'type' => 'image',
'order' => 4,
'group' => 'Admin',
])->save();
}
$setting = $this->findSetting('admin.google_analytics_client_id');
if (!$setting->exists) {
$setting->fill([
'display_name' => __('voyager::seeders.settings.admin.google_analytics_client_id'),
'value' => '',
'details' => '',
'type' => 'text',
'order' => 1,
'group' => 'Admin',
])->save();
}
}
/**
* [setting description].
*
* @param [type] $key [description]
*
* @return [type] [description]
*/
protected function findSetting($key)
{
return Setting::firstOrNew(['key' => $key]);
}
}

+ 231
- 0
database/seeds/TranslationsTableSeeder.php View File

@ -0,0 +1,231 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Category;
use TCG\Voyager\Models\DataType;
use TCG\Voyager\Models\MenuItem;
use TCG\Voyager\Models\Page;
use TCG\Voyager\Models\Translation;
class TranslationsTableSeeder extends Seeder
{
/**
* Auto generated seed file.
*
* @return void
*/
public function run()
{
$this->dataTypesTranslations();
$this->categoriesTranslations();
$this->pagesTranslations();
$this->menusTranslations();
}
/**
* Auto generate Categories Translations.
*
* @return void
*/
private function categoriesTranslations()
{
// Adding translations for 'categories'
//
$cat = Category::where('slug', 'category-1')->firstOrFail();
if ($cat->exists) {
$this->trans('pt', $this->arr(['categories', 'slug'], $cat->id), 'categoria-1');
$this->trans('pt', $this->arr(['categories', 'name'], $cat->id), 'Categoria 1');
}
$cat = Category::where('slug', 'category-2')->firstOrFail();
if ($cat->exists) {
$this->trans('pt', $this->arr(['categories', 'slug'], $cat->id), 'categoria-2');
$this->trans('pt', $this->arr(['categories', 'name'], $cat->id), 'Categoria 2');
}
}
/**
* Auto generate DataTypes Translations.
*
* @return void
*/
private function dataTypesTranslations()
{
// Adding translations for 'display_name_singular'
//
$_fld = 'display_name_singular';
$_tpl = ['data_types', $_fld];
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.post.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Post');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.page.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Página');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.user.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Utilizador');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.category.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Categoria');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.menu.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Menu');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.role.singular'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Função');
}
// Adding translations for 'display_name_plural'
//
$_fld = 'display_name_plural';
$_tpl = ['data_types', $_fld];
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.post.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Posts');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.page.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Páginas');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.user.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Utilizadores');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.category.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Categorias');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.menu.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Menus');
}
$dtp = DataType::where($_fld, __('voyager::seeders.data_types.role.plural'))->firstOrFail();
if ($dtp->exists) {
$this->trans('pt', $this->arr($_tpl, $dtp->id), 'Funções');
}
}
/**
* Auto generate Pages Translations.
*
* @return void
*/
private function pagesTranslations()
{
$page = Page::where('slug', 'hello-world')->firstOrFail();
if ($page->exists) {
$_arr = $this->arr(['pages', 'title'], $page->id);
$this->trans('pt', $_arr, 'Olá Mundo');
/**
* For configuring additional languages use it e.g.
*
* ```
* $this->trans('es', $_arr, 'hola-mundo');
* $this->trans('de', $_arr, 'hallo-welt');
* ```
*/
$_arr = $this->arr(['pages', 'slug'], $page->id);
$this->trans('pt', $_arr, 'ola-mundo');
$_arr = $this->arr(['pages', 'body'], $page->id);
$this->trans('pt', $_arr, '<p>Olá Mundo. Scallywag grog swab Cat o\'nine tails scuttle rigging hardtack cable nipper Yellow Jack. Handsomely spirits knave lad killick landlubber or just lubber deadlights chantey pinnace crack Jennys tea cup. Provost long clothes black spot Yellow Jack bilged on her anchor league lateen sail case shot lee tackle.</p>'
."\r\n".'<p>Ballast spirits fluke topmast me quarterdeck schooner landlubber or just lubber gabion belaying pin. Pinnace stern galleon starboard warp carouser to go on account dance the hempen jig jolly boat measured fer yer chains. Man-of-war fire in the hole nipperkin handsomely doubloon barkadeer Brethren of the Coast gibbet driver squiffy.</p>');
}
}
/**
* Auto generate Menus Translations.
*
* @return void
*/
private function menusTranslations()
{
$_tpl = ['menu_items', 'title'];
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.dashboard'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Painel de Controle');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.media'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Media');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.posts'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Publicações');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.users'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Utilizadores');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.categories'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Categorias');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.pages'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Páginas');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.roles'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Funções');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.tools'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Ferramentas');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.menu_builder'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Menus');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.database'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Base de dados');
}
$_item = $this->findMenuItem(__('voyager::seeders.menu_items.settings'));
if ($_item->exists) {
$this->trans('pt', $this->arr($_tpl, $_item->id), 'Configurações');
}
}
private function findMenuItem($title)
{
return MenuItem::where('title', $title)->firstOrFail();
}
private function arr($par, $id)
{
return [
'table_name' => $par[0],
'column_name' => $par[1],
'foreign_key' => $id,
];
}
private function trans($lang, $keys, $value)
{
$_t = Translation::firstOrNew(array_merge($keys, [
'locale' => $lang,
]));
if (!$_t->exists) {
$_t->fill(array_merge(
$keys,
['value' => $value]
))->save();
}
}
}

+ 28
- 0
database/seeds/VoyagerDatabaseSeeder.php View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Traits\Seedable;
class VoyagerDatabaseSeeder extends Seeder
{
use Seedable;
protected $seedersPath = __DIR__.'/';
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->seed('DataTypesTableSeeder');
$this->seed('DataRowsTableSeeder');
$this->seed('MenusTableSeeder');
$this->seed('MenuItemsTableSeeder');
$this->seed('RolesTableSeeder');
$this->seed('PermissionsTableSeeder');
$this->seed('PermissionRoleTableSeeder');
$this->seed('SettingsTableSeeder');
}
}

+ 27
- 0
database/seeds/VoyagerDummyDatabaseSeeder.php View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Seeder;
use TCG\Voyager\Traits\Seedable;
class VoyagerDummyDatabaseSeeder extends Seeder
{
use Seedable;
protected $seedersPath;
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->seedersPath = database_path('seeds').'/';
$this->seed('CategoriesTableSeeder');
$this->seed('UsersTableSeeder');
$this->seed('PostsTableSeeder');
$this->seed('PagesTableSeeder');
$this->seed('TranslationsTableSeeder');
$this->seed('PermissionRoleTableSeeder');
}
}

+ 1
- 0
hooks/hooks.json View File

@ -0,0 +1 @@
{}

+ 9
- 3
routes/web.php View File

@ -13,12 +13,18 @@ use App\Http\Controllers\ContentController;
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
Route::get('/don', function () {
return view('don');
});
//Route::get('/content', [ContentController::class, 'index']);
Route::get('/content/{path}', [ContentController::class, 'show']);
Route::get('/', [ContentController::class, 'home']);
Route::get('/category/{path}', [ContentController::class, 'index']);
Route::get('/search', [ContentController::class, 'search'])->name('content.search');
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});

Loading…
Cancel
Save