Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anders 2020-07-27 14:01:12 +02:00
commit 222a255fe7
7 changed files with 40 additions and 25 deletions

View File

@ -15,6 +15,6 @@ class Contact extends Model
{
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'name_first', "name_last", 'email', 'phone'
'contactname', "title", 'email', 'phone'
];
}

View File

@ -53,8 +53,8 @@ class ContactController extends Controller
public function store(Request $request)
{
$requestContact = $request->validate([
"name_first" => "required|max:255",
"name_last" => "required|max:255",
"contactname" => "required|max:255",
"title" => "required|max:255",
"email" => "required|max:255",
"phone" => "required|max:255",
]);

View File

@ -16,8 +16,8 @@ class CreateContact extends Migration
Schema::create('contacts', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('name_first', 255);
$table->string('name_last', 255);
$table->string('contactname', 255);
$table->string('title', 255);
$table->string('email', 255);
$table->integer('phone');
//$table->unique('email');

View File

@ -13,10 +13,10 @@
<h1>Opret Kontakt:</h1>
<form method="post" action="{{ route("contacts.store") }}">
@csrf
<label for="name_first">Fornavn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" required>
<label for="name_last">Efternavn:</label>
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" required>
<label for="contactname">Kontakt Navn:</label>
<input type="text" name="contactname" id="contactname" placeholder="Navn" required>
<label for="title">Titel:</label>
<input type="text" name="title" id="title" placeholder="Titel" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" required>
<label for="tel">Telefon nr:</label>

View File

@ -14,10 +14,10 @@
<form method="post" action="{{ route("contacts.update", ['contact' => $contact]) }}">
@csrf
@method("put")
<label for="name_first">Fornavn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" value="{{ $contact->name_first }}" required>
<label for="name_last">Efternavn:</label>
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" value="{{ $contact->name_last }}" required>
<label for="contactname">Kontakt Navn:</label>
<input type="text" name="contactname" id="contactname" placeholder="Navn" value="{{ $contact->contactname }}" required>
<label for="title">Titel:</label>
<input type="text" name="title" id="title" placeholder="Titel" value="{{ $contact->title }}" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" value="{{ $contact->email }}" required>
<label for="tel">Telefon nr:</label>

View File

@ -24,8 +24,8 @@
</tr>
@foreach($contacts as $contact)
<tr>
<td>{{ $contact->name_first }}</td>
<td>{{ $contact->name_last }}</td>
<td>{{ $contact->contactname }}</td>
<td>{{ $contact->title }}</td>
<td>{{ $contact->email }}</td>
<td>{{ $contact->phone }}</td>
<td><a href="{{ route("contacts.edit", [ "contact" => $contact ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>

View File

@ -20,19 +20,34 @@
<input type="text" name="name_last" id="name_last" value="{{ $user->name_last }}" required>
<label for="email">Email:</label>
<input type="email" name="email" id="email" value="{{ $user->email }}" required>
<label for="password1">Password:</label>
<input type="password" name="password" id="password1" value="" required>
<label for="password2">Confirm Password:</label>
<input type="password" id="password2" value="" required>
<label for="password1">Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" name="password" id="password1" value="">
<label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" id="password2" value="">
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
<label for="role">Rolle:</label>
<label for="role">Rolle: (Brug ctrl og shift til at vælge flere)</label>
<select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
<option disabled selected value> -- Vælg Rolle(r) -- </option>
<option value>Ingen Rolle</option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach
@if(count($user->roles) == 0)
<option disabled selected> -- Vælg Rolle(r) -- </option>
<option value>Ingen Rolle</option>
@foreach($roles as $role)
<option value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach
@else
<option disabled> -- Vælg Rolle(r) -- </option>
<option value>Ingen Rolle</option>
@foreach($roles as $role)
{{ $selected = "" }}
@foreach($user->roles as $userRole)
@if($userRole->id == $role->id)
{{ $selected = "selected" }}
@endif
@endforeach
<option {{ $selected }} value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach
@endif
</select>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>