本文整理汇总了PHP中Illuminate\Console\Scheduling\Schedule::call方法的典型用法代码示例。如果您正苦于以下问题:PHP Schedule::call方法的具体用法?PHP Schedule::call怎么用?PHP Schedule::call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Console\Scheduling\Schedule
的用法示例。
在下文中一共展示了Schedule::call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
// 进入维护模式
$schedule->command('down')->evenInMaintenanceMode()->dailyAt('23:00');
//->when(function () {return true;});//
// 更新用户等级
$schedule->call(function () {
$registrations = Registration::where('state', 0)->where(function ($query) {
$query->where('registration_date', Carbon::yesterday()->toDateString());
})->get();
foreach ($registrations as $registration) {
$user = $registration->user;
$user->credit_level -= 1;
$user->save();
}
})->evenInMaintenanceMode()->daily();
//
// 重置rest_num
$schedule->call(function () {
$doctor_schedules = DocSchedule::where('state', 0)->where(function ($query) {
$week = [1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday', 7 => 'sunday'];
$query->where('doctoring_date', $week[Carbon::today()->dayOfWeek]);
})->get();
foreach ($doctor_schedules as $doctor_schedule) {
$doctor_schedule->rest_num = $doctor_schedule->total_num;
$doctor_schedule->save();
}
})->evenInMaintenanceMode()->dailyAt('3:00');
//
// 离开维护模式
$schedule->command('up')->evenInMaintenanceMode()->dailyAt('7:00');
//
}
示例2: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
// $schedule->call('App\Http\Controllers\WelcomeController@testMail')->everyFiveMinutes();
$schedule->call('App\\Http\\Controllers\\API\\ShippingAPIController@autoCheckWaybill')->everyFiveMinutes();
$schedule->call('App\\Http\\Controllers\\API\\MailAPIController@registerInvitationMail')->everyFiveMinutes();
}
示例3: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
if (Schema::hasTable('migrations') && Schema::hasTable('users')) {
$banned = User::banned()->get();
$all = User::all();
$schedule->call(function () use($banned) {
foreach ($banned as $u) {
if ($u->banned_until != null) {
if ($u->banned_until < Carbon::now()->toDateTimeString()) {
$u->update(array('is_banned' => 0, 'banned_until' => null));
}
}
}
})->when(function () use($banned) {
return $banned->count() > 0;
})->cron('* * * * *');
$schedule->call(function () use($all) {
$now = Carbon::now();
$now->subMinutes(15);
// A user is offline if they do nothing for 15 minutes
foreach ($all as $u) {
if ($u->last_active != null && $u->last_active < $now->toDateTimeString()) {
$u->update(array('is_online' => 0));
}
}
})->when(function () use($all) {
return $all->count() > 0;
})->cron('* * * * *');
}
}
示例4: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
Mail::raw('Hi Dries!', function ($message) {
$message->from(env('MAIL_FROM'), env('MAIL_NAME'));
$message->to('driesvanschevensteen@me.com')->subject('Test mail!');
});
})->daily();
$schedule->call(function () {
$expiringAuctions = Auction::getExpiringAuctions();
foreach ($expiringAuctions as $auction) {
$bidders = Bid::getBiddersWithId($auction->id);
$highest = Bid::getHighestBidWithId($auction->id);
$auction->buyer_id = $highest->id;
$auction->save();
foreach ($bidders as $bidWithBidder) {
$bidder = $bidWithBidder->user;
if ($bidder->id = $highest->id) {
Mail::raw('Auction ' . $auction->title . ' ended, you are the highest bidder!', function ($message) use($bidder) {
$message->from(env('MAIL_FROM'), env('MAIL_NAME'));
$message->to($bidder->email)->subject('You are the highest bidder.');
});
} else {
Mail::raw('Auction ' . $auction->title . ' ended, you did not give the highest bid!', function ($message) use($bidder) {
$message->from(env('MAIL_FROM'), env('MAIL_NAME'));
$message->to($bidder->email)->subject("Auction ended, you didn't get it.");
});
}
}
}
})->daily();
}
示例5: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$players = DB::connection('game')->table('player_characters')->get();
foreach ($players as $player) {
if (!Player::where('id', $player->id)->exists()) {
$player_info = ['id' => $player->id, 'name' => $player->given_name, 'level' => $player->level, 'class' => 0, 'gold' => $player->gold, 'family_name' => $player->family_id ? DB::connection('game')->table('family')->where('id', $player->family_id)->first()->name : '-'];
Player::create($player_info);
}
}
})->everyTenMinutes();
$schedule->call(function () {
$families = DB::connection('game')->table('family')->get();
foreach ($families as $family) {
if (!Family::where('id', $family->id)->exists()) {
$gold = 0;
foreach (DB::connection('game')->table('player_characters')->where('family_id', $family->id)->get() as $player) {
$gold += $player->gold;
}
$family_info = ['id' => $family->id, 'name' => $family->name, 'level' => $family->lv, 'gold' => $gold, 'members' => DB::connection('game')->table('player_characters')->where('family_id', $family->id)->count(), 'leader' => DB::connection('game')->table('player_characters')->where('id', $family->leader_id)->first()->given_name];
Family::create($family_info);
}
}
})->everyTenMinutes();
}
示例6: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
//Change valid status of all tickets that no longer qualify as valid
$schedule->call(function () {
DB::table('tickets')->where('dateofdeparture', '<=', Carbon::now())->update(['valid' => 0]);
})->everyMinute();
//Decrement credits from users that have newly invalid tickets that are still tradable and mark them untradable once complete
$schedule->call(function () {
$where["valid"] = '0';
$where["tradable"] = '1';
$tickets = DB::table('tickets')->where($where)->get();
foreach ($tickets as $ticket) {
//Determine the credit value on the class of the ticket to set the decrement amount
switch ($ticket->class) {
case 'Economy':
$ticketValue = 1;
break;
case 'Business':
$ticketValue = 2;
break;
case 'First':
$ticketValue = 3;
break;
case 'Premium':
$ticketValue = 4;
break;
default:
$ticketValue = 1;
break;
}
DB::table('credits')->where('user_id', $ticket->user_id)->decrement('trade', $ticketValue);
DB::table('tickets')->where('id', $ticket->id)->update(['tradable' => 0]);
}
})->everyMinute();
}
示例7: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
$schedule->call(function () {
Log::info('attaching new verified skills started');
$skills = Skill::whereNotNull('verified_skill_id')->get();
foreach ($skills as $skill) {
$jobs = Job::whereHas('skills', function ($query) use($skill) {
$query->where('skill_id', $skill->id);
})->whereHas('verifiedSkills', function ($query) use($skill) {
$query->where('verified_skill_id', $skill->verified_skill_id);
}, '<', 1)->get();
foreach ($jobs as $job) {
$job->verifiedSkills()->attach($skill->verified_skill_id);
}
}
})->daily();
$schedule->call(function () {
Log::info('HH parsing started');
$hhGrabber = $this->app['App\\Helpers\\HeadHunterGrabber'];
$job = $this->app['App\\Models\\Job'];
$parser = new Parser([$hhGrabber], $job);
$parser->parse();
})->daily();
}
示例8: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
/*
* Let us know if there is something new :)
*/
// check if there is a new error
$schedule->call(function () {
// get new errors
$new_errors = Error::cronUnseen()->get();
if (!$new_errors->isEmpty()) {
Mail::send('emails.errors', ['errors' => $new_errors], function ($message) {
$message->from('notification@mygrades.de', 'Notification | MyGrades');
$message->to("hallo@mygrades.de", $name = null);
$message->subject("New errors reported");
});
// mark them as seen
DB::table('errors')->whereNull('cron_seen')->update(['cron_seen' => Carbon::now()]);
}
})->hourly();
// check if there is a new wish
$schedule->call(function () {
// get new errors
$new_wishes = Wish::cronUnseen()->get();
if (!$new_wishes->isEmpty()) {
Mail::send('emails.wishes', ['wishes' => $new_wishes], function ($message) {
$message->from('notification@mygrades.de', 'Notification | MyGrades');
$message->to("hallo@mygrades.de", $name = null);
$message->subject("New wishes");
});
// mark them as seen
DB::table('wishes')->whereNull('cron_seen')->update(['cron_seen' => Carbon::now()]);
}
})->hourly();
}
示例9: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
//check 'expired' confirmation tokens
$schedule->call('\\App\\Http\\Controllers\\EmergencyContactsController@expiredTokens')->hourly();
//check active trips
$schedule->call('\\App\\Http\\Controllers\\TripPlansController@missedTrips')->everyFiveMinutes();
}
示例10: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
Auction::end();
})->everyMinute();
$schedule->call(function () {
Auction::setPopular();
})->daily();
}
示例11: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// 5 day notice
$schedule->call(function () {
$FiveDaystoGo = \Carbon\Carbon::now()->addDays(5)->format("Y-m-d");
$usertools = \App\Models\Tool::where("retag_date", "=", $FiveDaystoGo)->where("five_notice", "=", "0")->get();
foreach ($usertools as $tool) {
$notification = new \App\Models\Notification();
$notification->message = '<a href="' . url("industryProject/public/tools/" . $tool->id) . '">' . $tool->name . '</a>' . " is due for re-tagging within the next five days.";
$notification->user_id = $tool->user_id;
$notification->save();
$tool->five_notice = 1;
$tool->save();
}
//send email
Mail::send('emails.fiveNotice', ['tool' => $tool], function ($m) {
$m->from('leanne.abarro@gmail.com', 'Tag and Track');
$m->to('leanne.abarro@gmail.com', 'Leanne')->subject('Tool is due to be re-tagged.');
});
})->dailyAt('04:00');
// 3 day notice
$schedule->call(function () {
$ThreeDaystoGo = \Carbon\Carbon::now()->addDays(3)->format("Y-m-d");
$usertools = \App\Models\Tool::where("retag_date", "=", $ThreeDaystoGo)->where("three_notice", "=", "0")->get();
foreach ($usertools as $tool) {
$notification = new \App\Models\Notification();
$notification->message = '<a href="' . url("industryProject/public/tools/" . $tool->id) . '">' . $tool->name . '</a>' . " is due for re-tagging within the next three days.";
$notification->user_id = $tool->user_id;
$notification->save();
$tool->three_notice = 1;
$tool->save();
}
//send email
Mail::send('emails.threeNotice', ['tool' => $tool], function ($m) {
$m->from('leanne.abarro@gmail.com', 'Tag and Track');
$m->to('leanne.abarro@gmail.com', 'Leanne')->subject('Tool is due to be re-tagged.');
});
})->dailyAt('05:00');
// 1 day notice
$schedule->call(function () {
$OneDaytoGo = \Carbon\Carbon::now()->addDays(1)->format("Y-m-d");
$usertools = \App\Models\Tool::where("retag_date", "=", $OneDaytoGo)->where("one_notice", "=", "0")->get();
foreach ($usertools as $tool) {
$notification = new \App\Models\Notification();
$notification->message = '<a href="' . url("industryProject/public/tools/" . $tool->id) . '">' . $tool->name . '</a>' . " is due for re-tagging tomorrow.";
$notification->user_id = $tool->user_id;
$notification->save();
$tool->one_notice = 1;
$tool->save();
}
//send email
Mail::send('emails.oneNotice', ['tool' => $tool], function ($m) {
$m->from('leanne.abarro@gmail.com', 'Tag and Track');
$m->to('leanne.abarro@gmail.com', 'Leanne')->subject('Tool is due to be re-tagged.');
});
})->dailyAt('06:00');
}
示例12: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('posts')->where('relevancia', '>', 5)->decrement('relevancia', 5);
DB::table('posts')->where('relevancia_rate', '>', 100)->decrement('relevancia_rate', 'relevancia_rate/100');
})->hourly();
$schedule->call(function () {
DB::table('posts')->where('relevancia_rate', '>', 5)->decrement('relevancia_rate', 1);
})->daily();
}
示例13: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->call(function () {
dispatch(new \App\Jobs\MTech\EmailEfficiencyReport());
})->twiceDaily(7, 19);
$schedule->call(function () {
dispatch(new \App\Jobs\MTech\LogoutShiftStaff());
})->twiceDaily(6, 18);
}
示例14: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
//It will excute the class SocialWorkerController at midnight and retrieve the user tags from facebook
$schedule->call("SmartCity\\Http\\Controllers\\SocialWorkerController@index")->daily();
// ->name("facebooktags")
// ->withoutOverlapping();
//It will excute the class FacebookPagesController every saturday and cities' Facebook pages posts
$schedule->call("SmartCity\\Http\\Controllers\\FacebookPagesController@index")->saturdays();
}
示例15: schedule
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
(new WebIOPi())->pin(3, 1);
})->dailyAt('23:00');
//5pm cst
$schedule->call(function () {
(new WebIOPi())->pin(3, 0);
})->dailyAt('04:30');
//10:30pm cst
}