我制作一个通知模块并显示缓存中的数据。
当我登录$ request时,它将生成数据。
[2018-12-04 14:56:22] local.INFO: array (
'id' => 12645261264,
'name' => 'hello-world',
'tags_url' => 'https://api.github.com/repos/anonymouse/hello-world/tags',
'archive_url' => 'https://api.github.com/repos/anonymouse/hello-world/{archive_format}{/ref}',
'updated_at' => '2018-12-04T06:28:02Z',
)
但是当id dd();没有数据返回null。
array:5 [▼
"id" => null
"name" => null
"tags_url" => null
"archive_url" => null
"updated_at" => null
]
这是我的完整代码...我没有记错..也许在缓存中。
public function index(Request $request){
view()->share('page_sub', 'Webhhook');
$data = $this->handle($request);
dd($data);
return view('pages.admin.system.webhook.index', compact('data'));
}
public function handle(Request $request){
$admins = User::whereHas('roles', function($q){$q->whereIn('roles.name', ['superadmin']);})->get();
$data = [
'id' => $request['repository']['id'],
'name' => $request['repository']['name'],
'tags_url' => $request['repository']['tags_url'],
'archive_url' => $request['repository']['archive_url'],
'updated_at' => $request['repository']['updated_at'],
];
$now = \Carbon\Carbon::now();
\Log::info($data);
if ($data->update_at != cache('updated_at')){
Cache::put('repo', $data, $now->addMonth(1));
} else {
Cache::get('repo');
}
foreach($admins as $user){
$user->notify(new WebhookNotification($repo_date));
}
return $data;
}