This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
ModuleWeb/SRC/app/Http/Controllers/AdminController.php

81 lines
1.4 KiB
PHP
Raw Normal View History

2015-02-12 20:00:23 +01:00
<?php namespace App\Http\Controllers;
use App\Referent;
2015-02-17 20:33:32 +01:00
use Input;
2015-02-18 01:21:24 +01:00
use Auth;
use Session;
2015-02-18 16:49:02 +01:00
use Request;
use Password;
2015-02-16 16:27:16 +01:00
2015-02-12 20:00:23 +01:00
class AdminController extends Controller {
2015-02-13 11:41:05 +01:00
2015-02-12 20:00:23 +01:00
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
2015-02-15 07:12:44 +01:00
//
2015-02-12 20:00:23 +01:00
}
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$user = Referent::all();
return view('backend/admin_home', ['nameRoute' => 'Admin', 'users' => $user]);
2015-02-12 20:00:23 +01:00
}
2015-02-17 15:56:30 +01:00
/**
* Add an user in database.
*
*
*/
public function addUser()
{
$user = new Referent;
$user->nom = Input::get('nom');
2015-02-17 20:33:32 +01:00
$user->email = Input::get('email');
$user->etablissement = Input::get('etablissement');
$user->prenom = Input::get('prenom');
$user->image = "imgs/avatar/default.jpg";
2015-02-17 20:33:32 +01:00
$user->save();
Password::sendResetLink(Input::only('email'));
return redirect('/admin')->with('message_add', 'Le référent a été ajouté.');
2015-02-18 00:01:05 +01:00
}
2015-02-17 20:33:32 +01:00
/**
* Delete an user
*
*/
public function deleteUser($idUser)
2015-02-17 20:33:32 +01:00
{
$user = Referent::find($idUser);
2015-02-17 21:57:41 +01:00
$user->delete();
return redirect('/admin')->with('message_delete', 'Le référent a été supprimé.');
2015-02-17 15:56:30 +01:00
}
2015-02-18 01:21:24 +01:00
/**
* Log as one user
*
*/
public function logAs($idUser)
2015-02-18 01:21:24 +01:00
{
// logout from Auth
Auth::logout();
// Log as referent
Auth::loginUsingId($idUser);
// Redirect referent route
return redirect('/referent');
}
2015-02-12 20:00:23 +01:00
}