관리-도구
편집 파일: UserController.php
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Hash; use App\User; class UserController extends Controller { public function getEmail($email = '') { $obj = User::where('email', $email)->first(); return $this->respon($obj); } public function getId($id = '') { $obj = User::find($id); return $this->respon($obj); } public function getAll() { $users = User::all(); return $this->respon($users); } public function getLogin($email = '', $pass = '') { $user = User::where('email', $email)->first(); $obj = $user; if($user){ if( Hash::check( $pass, $user->password) == false) { $obj = null; } } return $this->respon($obj); } private function respon($obj) { if (!$obj) { $obj = new User; } return response()->json([ 'data' => $obj->toArray() ]); } }