public function confirmEmailByToken($token) { $source = Source::whereEmailToken($token)->with(['customers', 'customers.samples' => function ($query) { $query->orderBy('created_at', 'desc'); }])->first(); if ($source) { $source->email_token = null; $source->email_confirmed = true; $source->save(); } return $source; }