Module build failed: Error: ENOENT: no such file or directory, scandir ‘*node_modules/node-sass/vendor’

14. December 2017 Laravel 0
在laravel中,运行npm install,一切正常,但在运行npm run dev 时候报错,如下: 在错误中,我发现Module build failed: Error: ENOENT: no such file or directory, scandir ‘/home/wwwroot/default/laravel5.5/node_modules/node-sass/vendor’这句话,看到目录下确实没有这个文件夹,然后执行 npm rebuild node-sass npm run dev 然后再运行就可以,具体造成此问题的原因不知,再次运行 npm run dev 就可了。 ERROR in ./node_modules/css-loader?{\"url\":true,\"sourceMap\":false,\"importLoaders\":1}!./node_modules/postcss-loader/lib?{\"sourceMap\":true,\"ident\":\"postcss\",\"plugins\":[null]}!./node_modules/resolve-url-loader?{\"sourceMap\":true,\"root\":\"/home/wwwroot/default/laravel5.5/node_modules\"}!./node_modules/sass-loader/lib/loader.js?{\"precision\":8,\"outputStyle\":\"expanded\",\"sourceMap\":true}!./resources/assets/sass/app.scss Module build failed: Error: ENOENT: no such file or directory, scandir \'/home/wwwroot/default/laravel5.5/node_modules/node-sass/vendor\' at Object.fs.readdirSync (fs.js:904:18) at Object.getInstalledBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/extensions.js:128:13) at foundBinariesList (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:20:15) at foundBinaries (/home/wwwroot/default/laravel5.5/node_modules/node-sass/lib/errors.js:15:5) ...

laravel从数组取数据实现分页功能

21. October 2017 Laravel 0
public function redisrest(Request $request) { $users = Redis::hgetall(Auth::id()); // var_dump($data); $perPage = 3; $currentPage = 1; if ($request->has(‘page’)) { $current_page = $request->input(‘page’); $current_page = $current_page <= 0 ? 1 : $current_page; } else { $current_page = 1; } $item = array_slice($users, ($current_page – 1) * $perPage, $perPage); //注释1 $total = count($users); $paginator = new LengthAwarePaginator($item, ...

laravel5.4添加自定义字端保存到表单中

10. August 2017 Laravel 0
第一步:添加字段stdid到users表中 php artisan make:migration add_stdid_to_users_table 然后打开生成的迁移文件,修改up方法 Schema::table(\'users\', function(Blueprint $table) { $table->string(\'stdid\'); }); 修改down方法 Schema::table(\'users\', function(Blueprint $table) { $table->dropColumn(\'stdid\'); }); 然后运行 php artisan make:migration add_stdid_to_users_table 第二步:打开register.blade.php,添加 <div class=\"form-group{{ $errors->has(\'stdid\') ? \' has-error\' : \'\' }}\"> <label for=\"stdid\" class=\"col-md-4 control-label\">学号</label> <div class=\"col-md-6\"> <input id=\"stdid\" type=\"text\" class=\"form-control\" name=\"stdid\" value=\"{{ old(\'stdid\') }}\" required autofocus> @if ($errors->has(\'stdid\')) <span class=\"help-block\"> <strong>{{ ...

laravel5.4 更换字段实现用户登录

10. August 2017 Laravel 0
Laravel默认使用 email 字段来认证。如果你想用其他字段认证,可以在 LoginController 里面定义一个 username 方法。 public function username() { return \'stdid\'; }添加此方法即可实现。 在LoginController中可以看到use AuthenticatesUsers 在AuthenticatesUsers.php中实现了登录,注销等逻辑,默认有 public function username() { return \'email\'; } 通过 return $this->guard()->attempt( $this->credentials($request), $request->has(\'remember\') );实现验证登录,在login.blade.php,在数据库表中,和控制器中,名称要一致,我使用stdid,如下 <input id=\"stdid\" type=\"text\" class=\"form-control\" name=\"stdid\" value=\"{{ old(\'stdid\') }}\" required autofocus>