本文整理汇总了PHP中App\Http\Controllers\Controller::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::error方法的具体用法?PHP Controller::error怎么用?PHP Controller::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Controller
的用法示例。
在下文中一共展示了Controller::error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* @param Request $request
* @return mixed
*/
public function store(Request $request)
{
$isUser = $this->isValid($request);
if ($isUser === false) {
return Controller::response(Controller::error(22), 401);
}
$request->session()->push('user', $isUser);
return Controller::response($isUser, 200);
}
示例2: store
/**
* @param Request $request
* @return mixed
*/
public function store(Request $request)
{
$validate = ['email' => 'required|email', 'password' => 'required'];
$validator = Controller::validator($request, $validate);
if ($validator !== true) {
return Controller::response(Controller::error(38), 400);
}
$isValid = $this->isValid($request);
if ($isValid !== true) {
return Controller::response(Controller::error(21), 400);
}
if ($request->hasFile('upload')) {
$file = $request->file('upload');
$name = uniqid(rand(), true) . "." . $file->getClientOriginalExtension();
$file->move('storage/', $name);
$request['picture'] = url('/storage') . "/" . $name;
}
$response = $this->user->pushUser($request);
return Controller::response($response, 200);
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$user = JWTAuth::parseToken()->authenticate();
if (!JWTAuth::parseToken()->authenticate()) {
return Controller::response(Controller::error(13), 401);
}
if ($user->id != $id && !Controller::supreme($user->role)) {
return Controller::response(Controller::error(13), 401);
}
$user = json_decode($this->user->pullUser($id));
if (!empty($user) || !collect($user)->isEmpty()) {
if ($user[0]->picture) {
$picture = str_replace(url('/storage') . "/", "", $user[0]->picture);
$target = public_path('storage/') . $picture;
@chmod($target, 0777 & ~umask());
File::delete($target);
}
}
$response = $this->user->deletePicture($id);
return Controller::response($response, 204);
}
示例4: authenticate
public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password', 'fid');
$token = null;
try {
if (!($token = JWTAuth::attempt($credentials))) {
return Controller::response(Controller::error(13), 401);
}
if (!empty($request->input('fid'))) {
$user = $this->user->authFacebook($request);
}
if (!empty($request->input('email'))) {
$user = $this->user->authEmail($request);
}
$hash = compact('token');
$user['token'] = $hash['token'];
return Controller::response($user, 200);
} catch (JWTException $e) {
return Controller::response(Controller::error(14), 500);
}
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$user = JWTAuth::parseToken()->authenticate();
if (!Controller::supreme($user->role)) {
return Controller::response(Controller::error(13), 401);
}
$response = $this->newsletter->deleteNewsletter($id);
return Controller::response($response, 204);
}