First Commit
This commit is contained in:
commit
0c9a118281
633 changed files with 76612 additions and 0 deletions
67
app/Http/Controllers/CronController.php
Normal file
67
app/Http/Controllers/CronController.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->checkConfirmation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
//delete user
|
||||
if ($user->confirmation_code_remider == 1) {
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
}
|
||||
//send new remider
|
||||
if ($user->confirmation_code_remider == 0) {
|
||||
Mail::to($user->email)->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue