在那里我试图安排一些任务在larave,但我发现很难安排我的任务在每20秒.检查laravel doc.对于laravel计划,它没有这样的方法秒.虽然有 - > cron('******')"在自定义Cron计划上运行任务",但它也无法解决我的问题.
下面是我在kernal.php文件中用于调度的代码.
protected function schedule(Schedule $schedule)
{
// need to replace everyMinute() by some other method which can run it every 20 sec
$schedule->call('path\to\controller@method)->everyMinute();
// also tried cron() but didn't workout.
$schedule->call('path\to\controller@method)->cron(*/20 * * * * *);
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我通过下面的代码使用javascript在刀片文件中设置cookie
function showPosition(position) {
var lat=position.coords.latitude;
var lng=position.coords.longitude;
document.cookie="lat=" + lat;
document.cookie="lng=" + lng;
//var allcookies = document.cookie;
//alert(allcookies);
localStorage.setItem('latLng',latLng);
}
Run Code Online (Sandbox Code Playgroud)
在模型中,我尝试获取Cookie
$lat = Cookie::get('lat');
$lng = Cookie::get('lng');
dd($lat);
Run Code Online (Sandbox Code Playgroud)
但它显示我为空。请帮忙。