Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login($data)
- {
- $username = $data['username'];
- $password = $data['password'];
- $executive = Executive::whereRaw("username LIKE '$username' AND password='$password'")->first();
- if(is_null($executive)) {
- return response()->json([
- 'code' => '403',
- 'app_message' => 'login unsuccessful, credentials mismatch'
- ]);
- }
- else {
- $executive->access_token = str_random(50);
- $executive->access_time = Carbon::now();
- $executive->save();
- return response()->json([
- 'code' => '403',
- 'app_message' => 'login success',
- 'access_token' => $executive->access_token,
- 'access_time' => $executive->access_time
- ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement