File: D:/HostingSpaces/egovers/edwingovers.nl/app/KommaApp/Auth/AuthService.php
<?php
namespace App\KommaApp\Auth;
use App\KommaApp\EndUsers\Models\EndUser;
use App\KommaApp\Members\Models\Member;
use App\KommaApp\Users\Models\User;
/**
* Short description for the file.
*
* @copyright (c) 2012-2015, Komma
*/
class AuthService
{
/**
* This method loads an account.
* Based in the type it will select the correct table
*
* @param $type
* @param $field
* @param $value
* @return mixed
*/
public function getAccountBy($type, $field, $value)
{
switch ($type) {
case 'user':
$account = $this->getUserBy($field, $value);
break;
case 'endUser' :
$account = $this->getEndUserBy($field, $value);
break;
}
return $account;
}
/**
* This method loads an user.
* Based on the field and value
*
* @param $field
* @param $value
* @return mixed
*/
private function getUserBy($field, $value)
{
if (!$user = User::where($field, $value)->first()) {
return false;
}
return $user;
}
/**
* This method loads an Customer.
* Based on the field and value
*
* @param $field
* @param $value
* @return mixed
*/
private function getEndUserBy($field, $value)
{
// if (!$user = EndUser::where($field, $value)->first()) {
if (!$user = User::where($field, $value)->first()) {
return false;
}
return $user;
}
/**
* Get an passwordReset from the db
*
* @param $type
* @param $token
* @return mixed
*/
public function getPasswordResets($type, $token)
{
if (!$reset = \DB::table('password_resets')
->where('type', $type)
->where('token', $token)->first()
) {
return false;
}
return $reset;
}
public function checkActive($type, $account){
//Check if account is not active
if ($account->active == 0) return false;
return true;
}
}