lebenlabs/simplecms

此包的最新版本(v3.0.0)没有提供许可证信息。

用于简化CMS的包

v3.0.0 2021-09-30 13:48 UTC

README

安装/配置

  • 安装包

      composer require "lebenlabs/simplecms=0.0.*"
  • 运行 composer dump-autoload

      composer dump-autoload
  • 运行包的 publish。在询问中选择包(Provider: Lebenlabs\SimpleCMS\SimpleCMSServiceProvider)

        php artisan vendor:publish
  • 运行 composer dump-autoload

      composer dump-autoload
  • 文件系统配置

        // Added for SimpleStorage package
        'archivos' => [
            'driver' => 'local',
            'root' => storage_path('app/archivos'),
        ],
    
        // Added for Lebenlabs\SimpleCMS package
        'simplecms_imagenes' => [
            'driver' => 'local',
            'root' => storage_path('app/public/lebenlabs_simplecms/imagenes/publicaciones'),
        ],
  • 运行迁移

  • 在 authenticable 中

        /* --------------------------*/
        
        abstract class Usuario implements Authenticatable, CanResetPassword, CanEditMenu, CanEditMenuItem, CanManagePublicaciones, CanViewPublicacion
        
        /* --------------------------*/
        
    
      /**
       * Returns true if the Entity can edit Menu
       *
       * @return boolean
       */
      public function canEditMenu()
      {
          return $this->esAdministrador();
      }
    
      /**
       * Returns true if the Entity can edit Menu Item
       *
       * @return bool
       */
      public function canEditMenuItem()
      {
          return $this->esAdministrador();
      }
    
      /**
       * Returns true if the Entity can manage publicaciones
       *
       * @return bool
       */
      public function canManagePublicaciones()
      {
          return $this->esAdministrador();
      }
    
      /**
       * @param Publicacion $publicacion
       * @return bool
       */
      public function canViewPublicacion(Publicacion $publicacion)
      {
          if ($this->esAdministrador()) {
              return true;
          }
    
          if ($publicacion->getPublicada()) {
              return true;
          }
    
          return false;
      }
      
         /* --------------------------*/      
        
  • 在 config/doctrine.php 中添加实体映射

      'paths'         => [
         ....
    
          // Lebenlabs/SimpleCMS package
          base_path('vendor/lebenlabs/simplecms/src/Models'),
    
          // SimpleStorage package
          base_path('vendor/lebenlabs/simplestorage/src/Models'),
        ....
    ]
  • 生成 doctrine 代理

  • 在后台包括 SimpleCMS 菜单项

      {{--Laravel Package - Lebenlabs\SimpleCMS--}}
      @include('Lebenlabs/SimpleCMS::Partials.header_shortcut')
  • 编辑上面发布的视图

  • 在布局中添加 CSS/JS

      {{--Laravel Package - Lebenlabs\SimpleCMS - CSS --}}
      @include('Lebenlabs/SimpleCMS::Partials.header_css')
    
      .....
    
      {{--Laravel Package - Lebenlabs\SimpleCMS - JS --}}
      @include('Lebenlabs/SimpleCMS::Partials.header_js')
  • 生成包的 JS/CSS。将行添加到 webpack.mix.js 中

     mix.
       -----
        // Lebenlabs - SimpleCMS - JS
      .js('vendor/lebenlabs/simplecms/src/Resources/Assets/js/SimpleCMS', 'public/js')
      .js('vendor/lebenlabs/simplecms/src/Resources/Assets/js/SummernoteHelper', 'public/js')
      .js('vendor/lebenlabs/simplecms/src/Resources/Assets/js/bootstrap-datetimepicker.min', 'public/js')
      
      ----
      // Lebenlabs - SimpleCMS - CSS
      .sass('vendor/lebenlabs/simplecms/src/Resources/Assets/css/bootstrap-datetimepicker.min', 'public/css')
  • 编译资源

      npm run dev
  • 通过以下命令创建菜单

      php artisan lebenlabs:simplecms:create-menu 

    注意:目前仅支持一个菜单 - 需要改进

  • 使用从应用程序注册的视图组合器加载要使用的菜单项(改进:选择特定菜单 - 多菜单的可能性)

      // ComposerServiceProvider
      public function boot()
      {
          View::composer(
              'Lebenlabs/SimpleCMS::Partials.Menu.show', SimpleCMSViewComposer::class
          );
      }
    
      // SimpleCMSViewComposer
      public function compose(View $view)
      {
          $view->with('rootMenuItems', $this->simpleCMS->findAllRootMenuItems());
      }