随笔分类 -  Laravel

摘要:Nuxt Child Component新建pages/users.vue文件,即与users文件夹相同层级且与users文件夹同名。代码如下:注意nuxt-child You can see me in all users related pages 结构如下:users文件夹中所有的与users相关的页面都在nuxt-child中渲染。打开:http://localhos... 阅读全文
posted @ 2020-05-12 14:32 dzkjz 阅读(52) 评论(0) 推荐(0)
摘要:layouts/default中的nuxt标签作为nuxt的插槽,pages/index.vue会渲染至此。新建pages/users.vueroute自动处理好了【必须有执行npm run dev】,打开 http://localhost:3000/users 即可看到页面结果。view page source因为:.nuxt/router.js中已经自动生成好了》》》Creating Nest... 阅读全文
posted @ 2020-05-12 00:29 dzkjz 阅读(72) 评论(0) 推荐(0)
摘要:安装Node.js,然后执行:npm install -g @vue-cli 安装vue-cli安装Nuxt.js【看官方文档】https://nuxtjs.org/guide/installation/新建一个文件夹:D:\nuxt ,文件夹内右键选择Terminal打开命令窗口:执行:npx create-nuxt-app learning然后:UI暂时不选择暂时不选择axios 都暂时不选择... 阅读全文
posted @ 2020-05-11 23:13 dzkjz 阅读(24) 评论(0) 推荐(0)
摘要:Main Topics:从上到下,从左至右。SSR->Nuxt->Deploy->Backend->Auth->…->ValidationNuxt.js:Vue.js基础之上的。 SPA page source一般是这样:所有的content在page source中是看不到的,搜索引擎爬取网站的时候,爬取的数据只有一个div#app,有的会缓一段时间等待render,对seo都不友好。其次,ro... 阅读全文
posted @ 2020-05-11 22:00 dzkjz 阅读(33) 评论(0) 推荐(0)
摘要:call(UserSeeder::class);// $this->call(QuestionTableSeeder::class); factory(\App\User::class, 3)->create()->each(function ($user) { $user->questions()->saveMany( ... 阅读全文
posted @ 2020-05-10 14:37 dzkjz 阅读(113) 评论(0) 推荐(0)
摘要:D:\laragon\www\laravel-qa>git branch * masterD:\laragon\www\laravel-qa>git checkout -b lesson-2 Switched to a new branch 'lesson-2'D:\laragon\www\laravel-qa>git statusOn branch lesson-2Changes not sta... 阅读全文
posted @ 2020-05-10 13:55 dzkjz 阅读(422) 评论(0) 推荐(0)
摘要:官方:https://www.howtographql.com/basics/0-introduction/官方:https://graphql.org/learn/参考:Laravel API 系列教程(四):基于 GraphQL 构建 Laravel API —— 基本使用篇Laravel API 系列教程(五):基于 GraphQL 构建 Laravel API —— 高级使用篇https:... 阅读全文
posted @ 2020-04-28 20:00 dzkjz 阅读(610) 评论(0) 推荐(0)
摘要:User.vue:为了做出这样的效果:那么选择Vuetify的 Datatable就很合适:且每一个都能支持编辑的,那么模板就用 CRUD Actions,拷贝它的代码:初步效果如下:接下来我们需要:api接口实现增删改获取用户数据。执行:php artisan make:controller Api\Admin\UserController –r会在Api\Admin文件夹下创建一个UserCo... 阅读全文
posted @ 2020-04-20 02:33 dzkjz 阅读(356) 评论(0) 推荐(0)
摘要:首先,用到了laravel ui扩展包 及基础的 vue 脚手架:执行:composer require laravel/ui执行:php artisan ui vue --auth执行:npm install & npm run watch介绍一下Laravel Permission 扩展包:A package to add roles and permissions to Laravelhtt... 阅读全文
posted @ 2020-04-18 21:52 dzkjz 阅读(724) 评论(0) 推荐(0)
摘要:如果我们有一些比较常见的JWT exception 可以 try catch处理 也可以在app\Exceptions\Handler.php的render方法内部处理:如:有多少加多少即可!但是如果需要很有针对性的返回信息,用try catch比较合适,render方法里比较粗糙但是简单。更多可以参考:Retreiving the Authenticated user from a token还... 阅读全文
posted @ 2020-04-17 01:35 dzkjz 阅读(610) 评论(0) 推荐(0)
摘要:iss (issuer):签发人sub (subject):主题aud (audience):受众exp (expiration time):过期时间nbf (Not Before):生效时间,在此之前是无效的iat (Issued At):签发时间jti (JWT ID):编号prv(private value):————————————————原文作者:skyArony转自链接:https:/... 阅读全文
posted @ 2020-04-17 01:23 dzkjz 阅读(2965) 评论(0) 推荐(0)
摘要:JWT相比Passport来说,轻便,功能一样完备,性价比高。参考JSON Web Token Authentication for Laravel & Lumen先来安装jwt扩展包:执行:composer require tymon/jwt-auth如果使用的Laravel是5.4及以下版本的;添加下面的代码 到config/app.php文件的providers配置数组中:'provider... 阅读全文
posted @ 2020-04-16 15:54 dzkjz 阅读(238) 评论(0) 推荐(0)
摘要:首先复制.env.example文件重命名为.env.testing:然后,执行:touch test.sqlite将在 D:/laragon/www/laraveauth 目录下生成一个test.sqlite文件:然后我们将.env.testing文件数据库配置修改为:DB_CONNECTION=sqliteDB_DATABASE="D:/laragon/www/laraveauth/test.... 阅读全文
posted @ 2020-04-16 00:44 dzkjz 阅读(236) 评论(0) 推荐(0)
摘要:如何生成api的使用文档:比如Blogger的Api这样的:方便你的用户来阅读使用。参考:https://laravel-apidoc-generator.readthedocs.io/en/latest/index.html执行:composer require mpociot/laravel-apidoc-generator执行:php artisan vendor:publish --pro... 阅读全文
posted @ 2020-04-15 01:42 dzkjz 阅读(662) 评论(0) 推荐(0)
摘要:默认情况下,Laravel提供了一个web的邮箱验证路由,Laravel 的 Auth\VerificationController 类包含了发送验证链接和验证 Email 的必要逻辑。通过将 verify 选项传给 Auth::routes 方法,就能为这个控制器注册所需要的路由:Auth::routes(['verify' => true]);没有api请求的。先复制一下Auth文件夹内的Ve... 阅读全文
posted @ 2020-04-15 00:38 dzkjz 阅读(636) 评论(0) 推荐(0)
摘要:执行:php artisan make:model Task –mf执行:php artisan make:controller TaskController -rid(); $table->unsignedBigInteger('user_id'); $table->string('title'); $table->text('d... 阅读全文
posted @ 2020-04-14 03:16 dzkjz 阅读(184) 评论(0) 推荐(0)
摘要:在 API 场景里通常通过令牌来实现用户授权,而非维护请求之间的 Session 状态。在 Laravel 项目中使用 Passport 可以轻而易举地实现 API 授权认证,Passport 可以在几分钟之内为你的应用程序提供完整的 OAuth2 服务端实现。安装:composer require laravel/passportPassport 服务提供器使用框架注册自己的数据库迁移目录因此在... 阅读全文
posted @ 2020-04-12 13:35 dzkjz 阅读(720) 评论(0) 推荐(0)
摘要:记录一次Authorization 异常的插曲:api.php有如下配置:Route::middleware('auth:api')->post('/userfollowOrUnFollowCelebrity', 'FollowController@followOrUnFollowCelebrity');FollowController构造函数及对应方法如下:public function __c... 阅读全文
posted @ 2020-04-05 01:40 dzkjz 阅读(2618) 评论(0) 推荐(0)
摘要:Laravel 中实现用户认证非常简单。实际上,几乎所有东西 Laravel 都已经为你配置好了。配置文件位于 config/auth.php,其中包含了用于调整认证服务行为的、文档友好的选项配置。在底层代码中,Laravel 的认证组件由“guards”和“providers”组成,Guard 定义了用户在每个请求中如何实现认证,例如,Laravel 通过 session guard 来维护 S... 阅读全文
posted @ 2020-04-04 22:20 dzkjz 阅读(671) 评论(0) 推荐(0)
摘要:在做前后台分离的项目中,认证是必须的,由于http是无状态的。前台用户登录成功后,后台给前台返回token。之后前台给后台发请求每次携带token。原理也非常简单:前台在请求头中添加 Authorization,如下后台取到值,然后去用户表的api_token列进行匹配,如果查到说明验证成功,并且返回相关信息。Laravel本身自带几种验证方式,下面介绍下token认证的实现的方法。前台在向后台发... 阅读全文
posted @ 2020-04-03 13:39 dzkjz 阅读(1924) 评论(0) 推荐(0)