$us= User::find($id);
$dev_id = Device::where("id", "=", $us->id)->get();
$id = DB::table('users')->insertGetId($users-> $request->name]);
public function register()
{
if(Sentinel::check()){
$companys = Company::where('user_id', Sentinel::getUser()->id)->get();
$dv = Device::where('user_id', Sentinel::getUser()->id)->get();
$hom = House::where('user_id', Sentinel::getUser()->id)->get();
$ass = Access::where('user_id', Sentinel::getUser()->id)->get();
$asc = Apartament::where('user_id', Sentinel::getUser()->id)->get();
}else{
$hom = House::get();
$companys = Company::get();
$dv = Device::get();
$ass = Access::get();
$asc = Apartament::get();
}
return view('auth.reg',compact('companys','hom','dv','ass','asc'));
}
public function postRegister(Request $request)
{
$token = str_random(32);
$users = [
'name' => request('name'),
'email' => request('email'),
'password' => request('password'),
'user_token' => ($token),
];
$user = Sentinel::registerandActivate($users);
$rolechosen = ($request->input('role'));
//Присвоение ролей
$admin_role = Sentinel::findRoleBySlug('admin');
$manager_role = Sentinel::findRoleBySlug('manager');
$user_role = Sentinel::findRoleBySlug('user');
if ($rolechosen == 'admin') {
$admin_role->users()->attach($user);
} elseif ($rolechosen == 'manager') {
$manager_role->users()->attach($user);
} elseif($rolechosen == 'user') {
$user_role->users()->attach($user);
}
return redirect('/profile');
}
public function devus(Request $request){
$id = DB::table('users')->insertGetId(['name'=>$request->name]);
DB:table('device')->insert([
['device' => $request->device, 'user_id' => $id]
]);
print_r($id);
}
if(Sentinel::inRole('manager')){
$role = Sentinel::findRoleById(3);
$us = $role->users()->with('roles')->get();
$companys = Company::get();