mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.9 KiB
Plaintext
121 lines
2.9 KiB
Plaintext
7 months ago
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Admin;
|
||
|
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use App\Http\Controllers\XController;
|
||
|
use App\Http\Requests\UserSaveRequest;
|
||
|
use App\Models\Access;
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Http\Request;
|
||
|
use App\Helper;
|
||
|
use function App\Helpers\hasCreateRoute;
|
||
|
|
||
|
class UserController extends XController
|
||
|
{
|
||
7 months ago
|
|
||
|
// protected $_MODEL_ = User::class;
|
||
|
// protected $SAVE_REQUEST = UserSaveRequest::class;
|
||
|
|
||
7 months ago
|
protected $cols = [];
|
||
7 months ago
|
protected $extra_cols = [];
|
||
7 months ago
|
|
||
|
protected $searchable = [];
|
||
|
|
||
7 months ago
|
protected $listView = 'admin.users.user-list';
|
||
|
protected $formView = 'admin.users.user-form';
|
||
7 months ago
|
|
||
|
|
||
|
protected $buttons = [
|
||
|
'edit' =>
|
||
|
['title' => "Edit", 'class' => 'btn-outline-primary', 'icon' => 'ri-edit-2-line'],
|
||
|
'show' =>
|
||
|
['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'],
|
||
|
'destroy' =>
|
||
|
['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'],
|
||
|
];
|
||
|
|
||
7 months ago
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct(User::class, UserSaveRequest::class);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param $user User
|
||
|
* @param $request UserSaveRequest
|
||
|
* @return User
|
||
|
*/
|
||
7 months ago
|
public function save($user, $request)
|
||
|
{
|
||
|
|
||
|
$user->save();
|
||
|
return $user;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Show the form for creating a new resource.
|
||
|
*/
|
||
|
public function create()
|
||
|
{
|
||
|
//
|
||
|
return view($this->formView);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for editing the specified resource.
|
||
|
*/
|
||
|
public function edit(User $item)
|
||
|
{
|
||
|
//
|
||
|
return view($this->formView, compact('item'));
|
||
|
}
|
||
|
|
||
|
public function bulk(Request $request)
|
||
|
{
|
||
|
|
||
|
// dd($request->all());
|
||
|
$data = explode('.', $request->input('action'));
|
||
|
$action = $data[0];
|
||
|
$ids = $request->input('id');
|
||
|
switch ($action) {
|
||
|
case 'delete':
|
||
|
$msg = __(':COUNT items deleted successfully', ['COUNT' => count($ids)]);
|
||
7 months ago
|
$this->_MODEL_::destroy($ids);
|
||
7 months ago
|
break;
|
||
|
/**restore*/
|
||
|
case 'restore':
|
||
|
$msg = __(':COUNT items restored successfully', ['COUNT' => count($ids)]);
|
||
|
foreach ($ids as $id) {
|
||
7 months ago
|
$this->_MODEL_::withTrashed()->find($id)->restore();
|
||
7 months ago
|
}
|
||
|
break;
|
||
|
/*restore**/
|
||
|
default:
|
||
|
$msg = __('Unknown bulk action : :ACTION', ["ACTION" => $action]);
|
||
|
}
|
||
|
|
||
|
return $this->do_bulk($msg, $action, $ids);
|
||
|
}
|
||
|
|
||
|
public function destroy(User $item)
|
||
|
{
|
||
|
return parent::delete($item);
|
||
|
}
|
||
|
|
||
|
|
||
|
public function update(Request $request, User $item)
|
||
|
{
|
||
|
return $this->bringUp($request, $item);
|
||
|
}
|
||
|
|
||
|
/**restore*/
|
||
|
public function restore($item)
|
||
|
{
|
||
|
return parent::restoreing(User::withTrashed()->where('id', $item)->first());
|
||
|
}
|
||
|
/*restore**/
|
||
|
}
|