PHP code example of yunjuji / yunjuji-generator

1. Go to this page and download the library: Download yunjuji/yunjuji-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yunjuji / yunjuji-generator example snippets


php artisan vendor:publish
php artisan infyom:publish
php artisan infyom.publish:layout

// tian add `mapCustomRoutes`
$this->mapCustomRoutes();

    /**
     * tian add
     * Define the "Custom" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapCustomRoutes()
    {
        /**
         * 加载 routes/web 文件夹下的路由
         */
        Route::group([
            'middleware' => ['web', 'admin', 'admin.bootstrap', 'admin.pjax', 'admin.log', 'admin.bootstrap', 'admin.permission'], // `laravel-admin` 有的中间件 'admin.auth', 'admin.pjax', 'admin.log', 'admin.bootstrap', 'admin.permission'
            'namespace'  => 'App\Http\Controllers',
            'prefix'     => 'admin',
        ], function ($router) {
            // Route::group(['middleware' => ['auth:' . config('inventory.base.guard'), 'menu', 'authAdmin']], function () {
            $routePath = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'web';
            $this->getFilePath($routePath);
            // });
        });
    }

    /**
     * [getFilePath 递归遍历文件]
     * @param  string $path [description]
     * @return [type]       [description]
     */
    protected function getFilePath($path = '.')
    {
        // opendir()返回一个目录句柄,失败返回false
        $current_dir = opendir($path);
        // readdir()返回打开目录句柄中的一个条目
        while (($file = readdir($current_dir)) !== false) {
            // 构建子目录路径
            $sub_dir = $path . DIRECTORY_SEPARATOR . $file;
            if ($file == '.' || $file == '..') {
                continue;
                // 如果是目录,进行递归
            } else if (is_dir($sub_dir)) {
                // echo $sub_dir . '<br />';
                $this->getFilePath($sub_dir);
            } else {
                // 如果是文件,直接输出
                $path = substr($path, strrpos($path, 'routes'));
                // echo base_path($path . DIRECTORY_SEPARATOR . $file) . '<br />';
                

php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"

php artisan admin:install

Migrating: 2016_01_04_173148_create_admin_tables
Migrated:  2016_01_04_173148_create_admin_tables
Admin directory was created: \app\Admin
HomeController file was created: \app\Admin/Controllers/HomeController.php
ExampleController file was created: \app\Admin/Controllers/ExampleController.php
Bootstrap file was created: \app\Admin/bootstrap.php
Routes file was created: \app\Admin/routes.php

列表:Route::get('entity/column/albums', ['as'=> 'entity.column.albums.index', 'uses' => 'Entity\Column\AlbumController@index']);
保存操作: Route::post('entity/column/albums', ['as'=> 'entity.column.albums.store', 'uses' => 'Entity\Column\AlbumController@store']);
新建视图: Route::get('entity/column/albums/create', ['as'=> 'entity.column.albums.create', 'uses' => 'Entity\Column\AlbumController@create']);
修改操作(全部修改): Route::put('entity/column/albums/{albums}', ['as'=> 'entity.column.albums.update', 'uses' => 'Entity\Column\AlbumController@update']);
修改操作(局部修改): Route::patch('entity/column/albums/{albums}', ['as'=> 'entity.column.albums.update', 'uses' => 'Entity\Column\AlbumController@update']);
删除操作: Route::delete('entity/column/albums/{albums}', ['as'=> 'entity.column.albums.destroy', 'uses' => 'Entity\Column\AlbumController@destroy']);
显示某条记录: Route::get('entity/column/albums/{albums}', ['as'=> 'entity.column.albums.show', 'uses' => 'Entity\Column\AlbumController@show']);
编辑视图: Route::get('entity/column/albums/{albums}/edit', ['as'=> 'entity.column.albums.edit', 'uses' => 'Entity\Column\AlbumController@edit']);