Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp
Conflicts: skolehjem/resources/views/app/layout/base.blade.php
This commit is contained in:
@@ -168,6 +168,15 @@ class ContactController extends Controller
|
||||
'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}else{
|
||||
$output.='<tr>'.
|
||||
'<td>Din søgning matchede ikke nogen personer</td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'</tr>';
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
|
||||
@@ -167,6 +167,14 @@ class EventController extends Controller
|
||||
'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}else{
|
||||
$output.='<tr>'.
|
||||
'<td>Intet match</td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'</tr>';
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
|
||||
@@ -164,6 +164,16 @@ class MenuPlanController extends Controller
|
||||
'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}else{
|
||||
$output.='<tr>'.
|
||||
'<td>Intet match</td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'</tr>';
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
|
||||
@@ -143,6 +143,13 @@ class rolesController extends Controller
|
||||
'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}else{
|
||||
$output.='<tr>'.
|
||||
'<td>Intet match</td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'</tr>';
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
|
||||
@@ -68,17 +68,18 @@ class UserController extends Controller
|
||||
"email" => "required|email|unique:users",
|
||||
"password" => "required|max:60",
|
||||
"phone" => "required|unique:users",
|
||||
"roles" => "max:255"
|
||||
|
||||
]);
|
||||
|
||||
// Log::debug("FINISHED VALIDATION?");
|
||||
|
||||
$rolez = $request->input("roles", [ "User" ]);
|
||||
|
||||
$user = new User($data);
|
||||
|
||||
// Log::debug("CREATED USER [NOT PERSISTED YET]");
|
||||
|
||||
$user->assignRole([ "R1", "R2" ]);
|
||||
$user->assignRole($rolez);
|
||||
$user->save();
|
||||
|
||||
// Log::debug("SAVED USER");
|
||||
@@ -166,16 +167,16 @@ class UserController extends Controller
|
||||
//$user->save();
|
||||
} else { // Else if you're not on the admin site (user site)
|
||||
if ($request->input('password') != null) { // If you're editing the password
|
||||
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back.
|
||||
return Response::detect("users.editpass");
|
||||
} elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back.
|
||||
return Response::detect("users.editpass");
|
||||
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message.
|
||||
return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Bekræft Nyt Password`!</p>');
|
||||
} elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back with fail message.
|
||||
return redirect()->route("users.accounteditpass")->with('error#oldpass', '<p class="text-center">Det indtastede password i `Nuværende Password` er ikke dit nuværende password!</p>');
|
||||
} else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.
|
||||
/** @var User $user */
|
||||
$user->update($data);
|
||||
Auth::logout();
|
||||
|
||||
return redirect()->route("users.login");
|
||||
return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center">Dit password er hermed ændret!</p>');
|
||||
}
|
||||
} else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
|
||||
$user->update($data);
|
||||
@@ -289,10 +290,13 @@ class UserController extends Controller
|
||||
$users = User::query()->where('name_first', 'LIKE',$request->search.'%')
|
||||
->orWhere('name_last','LIKE', $request->search.'%')
|
||||
->orWhere('phone','LIKE', $request->search.'%')
|
||||
->orWhere('email','LIKE',$request->search. '%')->get();
|
||||
->orWhere('email','LIKE',$request->search. '%')
|
||||
->orWhere('name','LIKE',$request->search. '%')
|
||||
->get();
|
||||
|
||||
if(count($users) !== 0){
|
||||
foreach ($users as $key => $user){
|
||||
|
||||
$roles = null;
|
||||
$rolesString = null;
|
||||
|
||||
@@ -314,7 +318,7 @@ class UserController extends Controller
|
||||
'<td>' . $user->name_last . '</td>'.
|
||||
'<td>' . $user->email . '</td>'.
|
||||
'<td>' . $user->phone .'</td>'.
|
||||
'<td>' . $rolesString .'</td>'.
|
||||
'<td>' . $user->name .'</td>'.
|
||||
'<td><a href="'. route("users.edit", [ "user" => $user->id ]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'.
|
||||
'<td><form method="post" action="' .route("users.destroy", [ "user" => $user->id ]). '" class="w-100 nostyle">'.
|
||||
csrf_field().
|
||||
@@ -325,6 +329,16 @@ class UserController extends Controller
|
||||
'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
}else{
|
||||
$output.='<tr>'.
|
||||
'<td>Intet match</td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'<td></td>'.
|
||||
'</tr>';
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\UserEvent;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class UserEventController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
// Get written data from events.index
|
||||
$data = $request->validate([
|
||||
"user_id" => "required|max:255",
|
||||
"event_id" => "required|max:255"
|
||||
]);
|
||||
|
||||
// Check the UserEvent table if there is a row that has the user_id AND the event_id
|
||||
$getTableInfo = UserEvent::where('user_id', $request->user_id)
|
||||
->where('event_id', $request->event_id)->get();
|
||||
|
||||
// If the row has both, then go back and show an error - Cause you're not allowed to be on the same event twice.
|
||||
if (count($getTableInfo) > 0)
|
||||
return redirect()->route("events.index")->with('error#' . $request->event_id, '<p class="text-center">Du har allerede tilmeldt dig denne Aktivitet!</p>');
|
||||
|
||||
// If not, then it keeps going and saves and shows a success message
|
||||
$UserEvent = new UserEvent($data);
|
||||
$UserEvent->save();
|
||||
|
||||
return redirect()->route("events.index")->with('signup#' . $request->event_id, '<p class="text-center">Du er hermed tilmeldt denne aktivitet!</p>');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user