108 lines
2.2 KiB
PHP
108 lines
2.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Admin;
|
||
|
|
||
|
use App\Facade\Theme;
|
||
|
use App\Facade\UserConfig;
|
||
|
use App\User;
|
||
|
use Illuminate\Http\Request;
|
||
|
|
||
|
use App\Http\Requests;
|
||
|
use App\Http\Controllers\Controller;
|
||
|
|
||
|
class UserController extends Controller
|
||
|
{
|
||
|
/**
|
||
|
* Display a listing of the resource.
|
||
|
*
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function index()
|
||
|
{
|
||
|
$this->authorize('admin-access');
|
||
|
|
||
|
$users = User::orderBy('name')
|
||
|
->paginate(UserConfig::get('items_per_page'));
|
||
|
|
||
|
return Theme::render('admin.list_users', [
|
||
|
'users' => $users
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for creating a new resource.
|
||
|
*
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function create()
|
||
|
{
|
||
|
$this->authorize('admin-access');
|
||
|
|
||
|
return Theme::render('admin.create_user');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Store a newly created resource in storage.
|
||
|
*
|
||
|
* @param \Illuminate\Http\Request $request
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function store(Requests\StoreUserRequest $request)
|
||
|
{
|
||
|
$this->authorize('admin-access');
|
||
|
|
||
|
$user = new User();
|
||
|
$user->fill($request->only(['name', 'email', 'password']));
|
||
|
$user->is_activated = true;
|
||
|
$user->is_admin = (strtolower($request->get('is_admin')) == 'on');
|
||
|
$user->save();
|
||
|
|
||
|
return redirect(route('user.index'));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Display the specified resource.
|
||
|
*
|
||
|
* @param int $id
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function show($id)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for editing the specified resource.
|
||
|
*
|
||
|
* @param int $id
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function edit($id)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Update the specified resource in storage.
|
||
|
*
|
||
|
* @param \Illuminate\Http\Request $request
|
||
|
* @param int $id
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function update(Request $request, $id)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Remove the specified resource from storage.
|
||
|
*
|
||
|
* @param int $id
|
||
|
* @return \Illuminate\Http\Response
|
||
|
*/
|
||
|
public function destroy($id)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
}
|