本文整理汇总了PHP中app\models\User::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP User::destroy方法的具体用法?PHP User::destroy怎么用?PHP User::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::destroy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Delete a user.
*
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy($id)
{
if (!auth()->user()->is_admin || auth()->user()->id === $id) {
abort(403);
}
return response()->json(User::destroy($id));
}
示例2: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
if ($id == 1) {
return redirect()->route('admin.user.index')->withErrors(array('Ошибка! Администратора системы удалить нельзя!'));
}
$this->users->destroy($id);
return redirect()->route('admin.user.index');
}
示例3: destroyUser
public function destroyUser($id)
{
$authUser = Auth::user();
$user = User::findOrFail($id);
if ($user->id == $authUser->id) {
return -1;
}
$result = User::destroy($id);
return $result;
}
示例4: destroy
public function destroy($id)
{
$user_id = Auth::user()->id;
$deleted_count = User::destroy($id);
if ($deleted_count > 0) {
Flash::success('Se ha borrado el usuario.');
} else {
Flash::error('Ocurrió un problema durante el borrado.');
}
return redirect($user_id != $id ? 'users' : '');
}
示例5: delete
public function delete($id = 0)
{
if (is_array(Input::get('ids'))) {
$id = Input::get('ids');
}
$ok = User::destroy($id);
if ($ok) {
return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('jump_url', URL::to('admin/user_list'))->with('message', "删除成功!");
} else {
return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('message', "删除失败!");
}
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if ($result = check_auth_to('YHLB_DELETE')) {
return $result;
}
try {
User::destroy($id);
return redirect()->action('Admin\\UserController@index')->with('operationstatus', 'sucess');
} catch (\Exception $e) {
return redirect()->back()->withErrors(['error' => '删除用户失败,请重试(' . $e->getMessage() . ')']);
}
}
示例7: updateUser
public function updateUser($parameters)
{
try {
$userLogs = new UserLogsService();
switch ($parameters['oper']) {
case 'changePassword':
$id = $parameters['id'];
$user = User::find(reset($id));
$validator = $this->getUserValidator($parameters, true, false, true);
if ($validator->fails()) {
throw new \Exception($validator->messages());
}
$user->password = $this->hashPassword($parameters['password']);
$user->save();
$userLogs->createUserLog($parameters);
return true;
break;
case 'generateApiKey':
$id = $parameters['ids'];
$user = User::find(reset($id));
Artisan::call('api-key:generate', array('--user-id' => $user->id));
$userLogs->createUserLog($parameters);
return true;
break;
case 'del':
$userLogs->createUserLog($parameters);
return User::destroy($parameters['ids']);
break;
case 'add':
$user = $this->newUser($parameters);
$userLogs->createUserLog($parameters);
break;
case 'edit':
// DB::table('campaign')->insert(
// array('id' => '572', 'name' => 'squaretraffic2')
// );
$id = $parameters['id'];
$user = User::find($id);
$validator = $this->getUserValidator($parameters, true, $user->email !== $parameters['email']);
if ($validator->fails()) {
throw new \Exception($validator->messages());
}
$userLogs->createUserLog($parameters);
break;
}
$columns = array_intersect_key($parameters, array_flip($user->getFillableColumns()));
if (!empty($columns)) {
$user->update($columns);
}
$relationships = array_intersect_key($parameters, array_flip(User::$relationshipsAllowedToUpdate));
if (!empty($relationships)) {
foreach ($relationships as $relationshipType => $relationshipValue) {
if (!empty($relationshipValue)) {
if (!is_array($relationshipValue)) {
$relationshipValue = explode(',', $relationshipValue);
}
$user->{$relationshipType}()->sync($relationshipValue);
}
}
}
return $user;
} catch (\Exception $e) {
throw $e;
}
}
示例8: getUserDelete
public function getUserDelete($id)
{
User::destroy($id);
return Redirect::to('admin')->with('message', 'Пользователь удален');
}
示例9: delete
function delete($id)
{
User::destroy($id);
}
示例10: destroy
public function destroy($id)
{
User::destroy($id);
return ['deleted' => true];
}
示例11: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
User::destroy($id);
return back()->with('info', '删除成功~');
}
示例12: destroy
/**
* @param $id
*
* @return int
*/
public function destroy($id)
{
return User::destroy($id);
}