This commit is contained in:
frederikpyt 2020-08-03 10:48:24 +02:00
commit 5ad6fb129b
9 changed files with 141 additions and 55 deletions

View File

@ -72,7 +72,7 @@ class EventController extends Controller
return Response::detect("events.store"); return Response::detect("events.store");
}else{ }else{
$event = Event::query()->paginate($request->input("limit", 20)); $event = Event::query()->paginate($request->input("limit", 20));
return Response::detect("events.index", ['events' => $event]); return redirect()->route("events.index", ['events' => $event]);
} }
} }
@ -175,7 +175,7 @@ class EventController extends Controller
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>".
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
"</tr>"; "</tr>";
$events = DB::table('events')->where('name', 'LIKE',$request->search.'%') $events = DB::table('events')->orderBY('date' , 'asc')->where('name', 'LIKE',$request->search.'%')
->orWhere('date','LIKE', $request->search.'%') ->orWhere('date','LIKE', $request->search.'%')
->get();//Job is here dude :9 ->get();//Job is here dude :9

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Feedbacks; use App\Feedbacks;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
class FeedbackController extends Controller class FeedbackController extends Controller
@ -125,4 +126,35 @@ class FeedbackController extends Controller
return Response::detect("feedbacks.destroy"); return Response::detect("feedbacks.destroy");
} }
public function search(Request $request){
if($request->ajax()){
$output = "<tr>".
"<th>Feedback Besked</th>".
"<th>Ris el. Ros</th>".
"</tr>";
//$value = Feedbacks::query('feedbacks')->select('suggestion_form ')->dump();
//$value = DB::table('feedbacks')->select('suggestion_form ')->dump();
if($request->option === "Ris" || $request->option === "Ros")
$feedbacks = Feedbacks::query()->orderBy('created_at', 'desc')->where('suggestion_form', '=', $request->option)
->get();
else
$feedbacks = Feedbacks::all();
if(count($feedbacks) !== 0){
foreach ($feedbacks as $key => $feedback){
$output.='<tr>'.
'<td>' . $feedback->message . '</td>'.
'<td>' . $feedback->suggestion_form . '</td>'.
'</tr>';
}
}
return Response($output);
}
}
} }

View File

@ -71,15 +71,19 @@ class UserController extends Controller
"phone" => "required|unique:users", "phone" => "required|unique:users",
]); ]);
$rolez = $request->input("roles", [ "User" ]); if ($request->password != $request->password2) {
return redirect()->route('users.create')->with('error#notsamepass', '<p>Der stod ikke det samme i `Password` & `Confirm Password`!</p>');
}
$roles = $request->input("roles", [ "User" ]);
$user = new User($data); $user = new User($data);
$user->assignRole($rolez); $user->assignRole($roles);
$user->save(); $user->save();
return Response::detect("users.store"); return redirect()->route('users.index');
} }
/** /**
@ -123,7 +127,6 @@ class UserController extends Controller
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
return redirect()->route("users.account");
$user = User::find($id); $user = User::find($id);
if($id === Auth::id() || auth()->user()->hasPermissionTo("user.edit")) { if($id === Auth::id() || auth()->user()->hasPermissionTo("user.edit")) {
@ -134,7 +137,7 @@ class UserController extends Controller
/** @var User $user */ /** @var User $user */
$user->update($data); $user->update($data);
} else // Else go back with an error message } else // Else go back with an error message
return redirect()->route("users.edit", ['user' => $id])->with('error#passnotsame', '<p>Der stod ikke det samme i `Password` & `Confirm Password`!</p>'); return redirect()->route("users.edit", ['user' => $id])->with('error#notsamepass', '<p>Der stod ikke det samme i `Password` & `Confirm Password`!</p>');
} }
else { // If you haven't touched the password, then update everything else but password else { // If you haven't touched the password, then update everything else but password
$data = $request->only(['name_first', 'name_last', 'email', 'phone', 'roles']); $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'roles']);
@ -148,27 +151,6 @@ class UserController extends Controller
foreach ($request->roles as $role) { foreach ($request->roles as $role) {
$user->assignRole($role); $user->assignRole($role);
} }
} else { // Else if you're not on the admin site (user site)
if ($request->input('password') != null) { // If you're editing the password
$data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']);
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")->with('success#passwordchange', '<p class="text-center text-white">Dit password er hermed ændret!</p>');
}
} else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
$data = $request->only(['email', 'phone']);
$user->update($data);
return redirect()->route("users.account")->with('success#credentialschanged', '<p class="text-center">Dine oplysninger er hermed ændret!</p>');
}
} }
} }
$users = User::query()->paginate(20); $users = User::query()->paginate(20);
@ -274,7 +256,7 @@ class UserController extends Controller
if ($request->input('password') != null) { // If you're editing the password if ($request->input('password') != null) { // If you're editing the password
$data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']); $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']);
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message. 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>'); return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Confirm 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. } 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>'); 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. } else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.

View File

@ -9,7 +9,20 @@
<a href="{{ route('feedbacks.index') }}" class="text-white">Vis Feedback</a> / <a href="{{ route('feedbacks.index') }}" class="text-white">Vis Feedback</a> /
@endsection @endsection
@section("content") @section("content")
<div class="risRos">
<label for="risros">Vælg type feedback:</label>
<select name="risRosName" id="risRosValue">
<option selected="selected" name="all" value="all">Alle</option>
<option name="ris" value="Ris">Ris</option>
<option name="ros" value="Ros">Ros</option>
</select>
</div>
<table class="tbl"> <table class="tbl">
<tr> <tr>
<th>Feedback Besked</th> <th>Feedback Besked</th>
@ -24,4 +37,27 @@
</table> </table>
{{ $feedback->links() }} {{ $feedback->links() }}
<script>
$('#risRosValue').change(function () {
$value = $('#risRosValue').find(":selected").val();
$.ajax({
type: 'get',
url: '{{route('feedbacks.search')}}',
data: {'option':$value},
success:function (data) {
console.log($value);
$('tbody').html(data);
},
error:function (data) {
console.log(data);
}
});
})
</script>
@endsection @endsection

View File

@ -11,6 +11,7 @@
@section("content") @section("content")
<h1>Opret Bruger:</h1> <h1>Opret Bruger:</h1>
{!! session()->get('error#notsamepass') !!}
<form method="post" action="{{ route("users.store") }}"> <form method="post" action="{{ route("users.store") }}">
@csrf @csrf
<label for="name_first">Fornavn:</label> <label for="name_first">Fornavn:</label>
@ -20,9 +21,15 @@
<label for="email">Email:</label> <label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" required> <input type="email" name="email" id="email" placeholder="x@y.z" required>
<label for="password1">Password:</label> <label for="password1">Password:</label>
<input type="password" name="password" placeholder="Password" id="password1" required> <div class="input-group text-left">
<label for="password2">Bekræft Password:</label> <input type="password" class="form-control" name="password" id="password1" placeholder="******" required>
<input type="password" id="password2" placeholder="Bekræft Password" required> <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span>
</div>
<label for="password2">Confirm Password:</label>
<div class="input-group text-left">
<input type="password" class="form-control" name="password2" id="password2" placeholder="******" required>
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span>
</div>
<label for="tel">Telefon nr:</label> <label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" placeholder="12345678" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required> <input type="tel" name="phone" id="tel" placeholder="12345678" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required>
<label for="roles">Rolle:</label> <label for="roles">Rolle:</label>
@ -36,3 +43,20 @@
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" class="btn btn-dark text-white" value="Opret">
</form> </form>
@endsection @endsection
@section("scripts")
<script>
function show($passID, $faID) {
var inputPass = document.getElementById($passID);
var faEye = document.getElementById($faID);
if (inputPass.type === "password") {
inputPass.type = "text";
faEye.style.color = "#000";
} else {
inputPass.type = "password";
faEye.style.color = "#808080";
}
}
</script>
@endsection

View File

@ -11,8 +11,8 @@
@section("content") @section("content")
<h1>Rediger Bruger:</h1> <h1>Rediger Bruger:</h1>
{!! session()->get('error#passnotsame') !!} {!! session()->get('error#notsamepass') !!}
<form method="post" action="{{ route("users.update", ['user' => $user]) }}" style="display: inline-table;"> <form method="post" action="{{ route("users.update", ['user' => $user]) }}">
@csrf @csrf
@method("put") @method("put")
<label for="name_first">Fornavn:</label> <label for="name_first">Fornavn:</label>
@ -22,11 +22,15 @@
<label for="email">Email:</label> <label for="email">Email:</label>
<input type="email" name="email" id="email" value="{{ $user->email }}" required> <input type="email" name="email" id="email" value="{{ $user->email }}" required>
<label for="password1">Password: (Forblives blank, hvis password ikke skal ændres)</label> <label for="password1">Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" name="password" id="password1" value="" placeholder="******"> <div class="input-group text-left">
<span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span> <input type="password" class="form-control" name="password" id="password1" value="" placeholder="******">
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span>
</div>
<label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label> <label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" name="password2" id="password2" value="" placeholder="******"> <div class="input-group text-left">
<span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span> <input type="password" class="form-control" name="password2" id="password2" value="" placeholder="******">
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span>
</div>
<label for="tel">Telefon nr:</label> <label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required> <input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
<label for="role">Rolle: (Brug ctrl og shift til at vælge flere)</label> <label for="role">Rolle: (Brug ctrl og shift til at vælge flere)</label>
@ -54,19 +58,6 @@
</select> </select>
<input type="submit" class="btn btn-dark text-white" value="Rediger"> <input type="submit" class="btn btn-dark text-white" value="Rediger">
</form> </form>
<style>
input {
width: calc(100% - 8px);
}
.fa-eye {
position: absolute;
font-size: 25px;
color: grey;
margin: 7.5px 0 0 -45px;
}
</style>
@endsection @endsection
@section("scripts") @section("scripts")

View File

@ -7,7 +7,7 @@
@section("content") @section("content")
<main> <main>
<h1 class="text-center sde-blue mt-0">Konto</h1> <h1 class="text-center sde-blue mt-0">Konto</h1>
<form method="post" action="{{ route("users.accountupdate", ['user' => Auth::user()]) }}" style="display: inline-table;"> <form method="post" action="{{ route("users.accountupdate", ['user' => Auth::user()]) }}">
@csrf @csrf
@method("put") @method("put")
<span>Nuværende Password:</span> <span>Nuværende Password:</span>
@ -20,7 +20,7 @@
<input type="password" class="form-control" name="password" id="new" placeholder="******" required> <input type="password" class="form-control" name="password" id="new" placeholder="******" required>
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span> <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
</div> </div>
<span>Bekræft Nyt Password:</span> <span>Confirm Password:</span>
<div class="input-group text-left"> <div class="input-group text-left">
<input type="password" class="form-control" name="confirmpassword" id="confirm" placeholder="******" required> <input type="password" class="form-control" name="confirmpassword" id="confirm" placeholder="******" required>
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span> <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>

View File

@ -12,7 +12,10 @@
<form action="{{ route("users.login") }}" method="post"> <form action="{{ route("users.login") }}" method="post">
@csrf @csrf
<input class="appinput" type="email" name="email" placeholder="Email" required> <input class="appinput" type="email" name="email" placeholder="Email" required>
<input class="appinput" type="password" name="password" placeholder="Password" required> <div class="input-group text-left">
<input type="password" class="appinput form-control" name="password" id="password" placeholder="Password" required>
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-password" onclick="show('password', 'fa-password')" style="background-color: #00788a; color: white;"></span>
</div>
<label class="toggle"> <label class="toggle">
<input class="toggle__input" type="checkbox" name="rememberpassword"> <input class="toggle__input" type="checkbox" name="rememberpassword">
<span class="toggle__label"> <span class="toggle__label">
@ -25,3 +28,20 @@
<a class="text-white text-center" href="{{ route('users.show-forgot') }}">Forgot password?</a> <a class="text-white text-center" href="{{ route('users.show-forgot') }}">Forgot password?</a>
</main> </main>
@endsection @endsection
@section("scripts")
<script>
function show($passID, $faID) {
var inputPass = document.getElementById($passID);
var faEye = document.getElementById($faID);
if (inputPass.type === "password") {
inputPass.type = "text";
faEye.style.color = "#999";
} else {
inputPass.type = "password";
faEye.style.color = "#fff";
}
}
</script>
@endsection

View File

@ -29,13 +29,14 @@ Route::get("/events/signups", "EventController@signups")->name("events.signups")
Route::get("phones", "PhoneController@index")->name("phones.index"); Route::get("phones", "PhoneController@index")->name("phones.index");
Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api"); Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
//Search/Filter
Route::get("/contactsapi", "ContactController@search")->name("contacts.search"); Route::get("/contactsapi", "ContactController@search")->name("contacts.search");
Route::get("/eventsapi", "EventController@search")->name("events.search"); Route::get("/eventsapi", "EventController@search")->name("events.search");
Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search"); Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search");
Route::get("/rolesapi", "RolesController@search")->name("roles.search"); Route::get("/rolesapi", "RolesController@search")->name("roles.search");
Route::get("/userapi", "UserController@search")->name("users.search"); Route::get("/userapi", "UserController@search")->name("users.search");
Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search"); Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search");
Route::get("/risrosapi", "FeedbackController@search")->name("feedbacks.search");