/images/avatar.png

Laravel 填充数据

database/factories/StatusFactory.php 1 2 3 4 5 6 7 8 9 10 11 12 <?php use Faker\Generator as Faker; $factory->define(App\Models\Status::class, function (Faker $faker) { $date_time = $faker->date . ' ' . $faker->time; return [ 'content' => $faker->text(), 'created_at' => $date_time, 'updated_at' => $date_time, ]; }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class StatusesTableSeeder extends Seeder { /** *

Laravel 修改未登录状态跳转的路由

app/Exceptions/Handler.php 里新增以下方法: 1 2 3 4 5 6 7 8 9 10 11 12 use Illuminate\Auth\AuthenticationException; protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest('login'); //<----- 修改这里 }

LVS 与 Nginx

什么时候用? 先说结论:项目前期使用 Nginx + Keepalived 足以应付很多场景/ 网站建设初期(每日 PV 小于 100 万),可以选用 Nigix 作为反向代理负载均衡,因为其配置简单,性

Mac DNS 错误 域名解析不了 ping: cannot resolve Unknown host

如果出现 ping: cannot resolve www.baidu.com: Unknown host 连上网络后却无法访问 唤醒后无法上网 可通过如下命令解决: 1 2 sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist 上述简化为一条命令: 1 sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist && sudo launchctl load -w

mysql 主从设置

1 2 3 4 5 6 7 #主数据库设置 server-id = 1 log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 10 max_binlog_size = 100M binlog_do_db = important_db #binlog_ignore_db = include_database_name 1 2 3 4 5 6 7 8 9 10 11 12 13 CREATE USER 'slave'@'%' IDENTIFIED BY 'mysql'; GRANT SELECT,REPLICATION SLAVE ON *.* TO 'slave'@'%'; #查询主数据库状态 mysql> show master