Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
forbidals
/
admin_panel
/
app
/
Http
/
Controllers
/
Auth
:
VerificationController.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Models\School; use App\Models\User; use App\Providers\RouteServiceProvider; use Illuminate\Auth\Events\Verified; use Illuminate\Foundation\Auth\VerifiesEmails; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; class VerificationController extends Controller { /* |-------------------------------------------------------------------------- | Email Verification Controller |-------------------------------------------------------------------------- | | This controller is responsible for handling email verification for any | user that recently registered with the application. Emails may also | be re-sent if the user didn't receive the original email message. | */ use VerifiesEmails; /** * Where to redirect users after verification. * * @var string */ protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); $this->middleware('signed')->only('verify'); $this->middleware('throttle:6,1')->only('verify', 'resend'); } /** * Mark the authenticated user's email address as verified. * Overridden to sync verification status to the main MySQL database. */ public function verify(Request $request) { if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) { throw new \Illuminate\Auth\Access\AuthorizationException; } if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) { throw new \Illuminate\Auth\Access\AuthorizationException; } if ($request->user()->hasVerifiedEmail()) { return redirect($this->redirectPath()); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } // Sync email_verified_at to the main MySQL database DB::connection('mysql')->table('users') ->where('id', $request->user()->id) ->update(['email_verified_at' => $request->user()->email_verified_at]); // Sync to school database if applicable $user = $request->user(); if ($user->school_id) { $school = School::on('mysql')->where('id', $user->school_id)->first(); if ($school) { Config::set('database.connections.school.database', $school->database_name); DB::purge('school'); DB::connection('school')->reconnect(); User::on('school')->where('id', $user->id)->update(['email_verified_at' => $user->email_verified_at]); } } return redirect($this->redirectPath())->with('verified', true); } }