Fixed - Guides

Added - contacts visual (controller coming soon)
This commit is contained in:
Anders 2020-08-05 09:23:57 +02:00
parent b4634d4933
commit a78e7d90f6
9 changed files with 83 additions and 12 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 = [
'contactname', "title", 'email', 'phone'
'contactname', "title", 'email', 'phone', 'phonetimes'
];
}

View File

@ -64,10 +64,10 @@ class GuideController extends Controller
$saved = $guide->save();
if(!$saved){
return Response::detect("guides.store");
return redirect()->route("guides.store");
}else{
$guide = Guide::query()->paginate($request->input("limit", 20));
return Response::detect("guides.index", ['guides' => $guide]);
return redirect()->route("guides.index", ['guides' => $guide]);
}
}

View File

@ -22,7 +22,7 @@ class CreateContact extends Migration
$table->string('title', 255);
$table->string('email', 255);
$table->integer('phone');
//$table->unique('email');
$table->string('phonetimes');
});
}

View File

@ -10,6 +10,13 @@
@endsection
@section("content")
<style>
.ck-editor__main {
margin-bottom: 1rem;
}
</style>
<script src="https://cdn.ckeditor.com/ckeditor5/21.0.0/classic/ckeditor.js"></script>
<h1>Opret Kontakt:</h1>
<form method="post" action="{{ route("contacts.store") }}">
@csrf
@ -21,6 +28,26 @@
<input type="email" name="email" id="email" placeholder="x@y.z" required>
<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>
<label for="teltimes">Telefon tider: (Forblives blank, hvis der ikke er nogen bestemte tider)</label>
<textarea name="phonetimes" id="editor"></textarea>
<input type="submit" class="btn btn-dark text-white" value="Opret">
</form>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ), {
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote' ],
heading: {
options: [
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
{ model: 'heading1', view: 'h3', title: 'Heading 1', class: 'sde-blue' },
{ model: 'heading2', view: 'h4', title: 'Heading 2', class: 'sde-blue' }
]
}
} )
.catch( error => {
console.log( error );
} );
</script>
@endsection

View File

@ -10,6 +10,13 @@
@endsection
@section("content")
<style>
.ck-editor__main {
margin-bottom: 1rem;
}
</style>
<script src="https://cdn.ckeditor.com/ckeditor5/21.0.0/classic/ckeditor.js"></script>
<h1>Rediger Kontakt:</h1>
<form method="post" action="{{ route("contacts.update", ['contact' => $contact]) }}">
@csrf
@ -22,6 +29,26 @@
<input type="email" name="email" id="email" placeholder="x@y.z" value="{{ $contact->email }}" required>
<label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" placeholder="12345678" value="{{ $contact->phone }}" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required>
<label for="teltimes">Telefon tider: (Forblives blank, hvis der ikke er nogen bestemte tider)</label>
<textarea name="phonetimes" id="editor">{{ $contact->phonetimes }}</textarea>
<input type="submit" class="btn btn-dark text-white" value="Opret">
</form>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ), {
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote' ],
heading: {
options: [
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
{ model: 'heading1', view: 'h3', title: 'Heading 1', class: 'sde-blue' },
{ model: 'heading2', view: 'h4', title: 'Heading 2', class: 'sde-blue' }
]
}
} )
.catch( error => {
console.log( error );
} );
</script>
@endsection

View File

@ -23,7 +23,7 @@
<label for="title">Navn</label>
<input value="{{$guide->name}}" type="text" name="name" id="title" required>
<label for="editor">Vejledning</label>
<textarea name="guide_articles" id="editor">{{$guide->guideArticles}}</textarea>
<textarea name="guide_articles" id="editor">{{$guide->guide_articles}}</textarea>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>

View File

@ -5,6 +5,22 @@
@section("content")
<main>
<h1 class="text-center sde-blue mt-0">Kontakt</h1>
@if(!$contacts->isEmpty())
@foreach($contacts as $contact)
<h4 class="mt-0">Navn: {{ $contact->contactname }}</h4>
<h4 class="mt-0">Email: {{ $contact->email }}</h4>
<h4 class="mt-0">{{ $contact->title }}</h4>
@if($contact->phonetimes)
<h4 class="mt-0 mb-0">Telefontid:</h4>
{!! $contact->phonetimes !!}
@endif
<span class="text-center sde-black-20 mt-1">+45 {{ chunk_split($contact->phone, 2, ' ') }}</span>
<a class="btn text-center btn-sde-blue mt-1" href="tel:+45{{ $contact->phone }}">Ring</a>
@endforeach
@else
<p class="text-center">Der er ingen kontakter!</p>
@endif
<h1 class="text-center sde-blue mt-0">Kontakt</h1>
<h4 class="mt-0">Navn: Claus Trasbo</h4>
<h4 class="mt-0">Email: ctr@sde.dk</h4>

View File

@ -12,12 +12,13 @@
</style>
<main>
<h1 class="text-center sde-blue mt-0">Vejledninger</h1>
@foreach($guides as $guide)
<h2 class="text-center sde-blue mt-0">{{ $guide->name }}</h2>
{!! $guide->guide_articles !!}
<hr class="w-100">
@endforeach
@if(count($guides) < 1)
@if(!$guides->isEmpty())
@foreach($guides as $guide)
<h2 class="text-center sde-blue mt-0">{{ $guide->name }}</h2>
{!! $guide->guide_articles !!}
<hr class="w-100">
@endforeach
@else
<p style="margin: 0 18px;">Der er ingen vejledninger.</p>
@endif
</main>

View File

@ -45,7 +45,7 @@
</a>
<a href="{{ route("guides.index") }}">
<img src="{{URL::asset('/images/icons/Vejledninger.svg')}}" alt="Guide">
Vejledning
Vejledninger
</a>
<a href="{{ route("users.account") }}">
<img src="{{URL::asset('/images/icons/user-hvid.svg')}}" alt="Konto">