Last active
July 19, 2018 12:46
-
-
Save kneipp/4fc734dfe081dfeb8050649504217a1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-attributes: array:4 [ | |
"oauth_access_token_id" => "0d66b551f7953d6058e9a5824a6c46b55d97d72f38a6623465f32ab8exxxxxxxxxxxxxxxxxxxxxx" | |
"oauth_client_id" => "5" | |
"oauth_user_id" => "" | |
"oauth_scopes" => [] | |
<?php | |
namespace App; | |
use Illuminate\Http\Request; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
use Laravel\Passport\HasApiTokens; | |
class User extends Authenticatable | |
{ | |
use Notifiable, HasApiTokens; | |
const ID_STARTS_IN = 1; | |
const MAX_SIGNED_INT = 2147483647; | |
protected $table = 'user'; | |
protected $primaryKey = 'usr_id'; | |
protected $hidden = ['usr_credential', 'remember_token']; | |
protected $fillable = [ | |
'usr_id', | |
'usr_nm', | |
'usr_credential', | |
'usr_email' | |
]; | |
public $timestamps = false; | |
public function findForPassport($username) { | |
return $this->where('usr_id', $username)->first(); | |
} | |
protected static function rules(Request $request, $update = false) | |
{ | |
$unique = 'user'; | |
if($update && $request->has('usr_email')) { | |
$unique = 'user,usr_email,'.$request->usr_email.',usr_email'; | |
} | |
return [ | |
'usr_nm' => 'required|max:200', | |
'prf_id' => 'required|between:'.self::ID_STARTS_IN.','.self::MAX_SIGNED_INT.'|integer', | |
'usr_credential' => 'nullable|max:512', | |
'usr_email' => 'required|email|max:100|unique:' . $unique | |
]; | |
} | |
protected static function isValid($id) | |
{ | |
return User::where('usr_id', $id)->first(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment