Made it so they can now make there own dynamic guide
This commit is contained in:
parent
e8f6c2242a
commit
c223cb967c
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Guide extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name', 'guideArticles'
|
||||
];
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Guide;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GuideController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
|
||||
$this->middleware([ "check.auth:contact.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:contact.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:contact.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:contact.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:contact.delete" ])->only("delete");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$guides = Guide::query()->paginate($request->input("limit", 20));
|
||||
|
||||
return Response::detect("guides.index", [ "guides" => $guides]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return Response::detect("guides.create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
//Me no sure what to store mester big smoke :)
|
||||
$requestGuide = $request->validate([
|
||||
"name" => "required|max:255",
|
||||
"guideArticles" => "required",
|
||||
]);
|
||||
|
||||
$guide = new Guide($requestGuide);
|
||||
$saved = $guide->save();
|
||||
|
||||
if(!$saved){
|
||||
return Response::detect("guides.store");
|
||||
}else{
|
||||
$guide = Guide::query()->paginate($request->input("limit", 20));
|
||||
return Response::detect("guides.index", ['guides' => $guide]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Guide $guide
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Guide $guide)
|
||||
{
|
||||
return Response::detect("guides.show", [ "guide" => $guide]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Guide $guide
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Guide $guide)
|
||||
{
|
||||
$guidee = Guide::query()->where("id", "=", $guide->id)->first();
|
||||
return Response::detect("guides.edit", ["guide" => $guidee]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Guide $guide
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Guide $guide)
|
||||
{
|
||||
$data = $request->validate([
|
||||
"name" => "required|max:255",
|
||||
"guideArticles" => "required",
|
||||
]);
|
||||
|
||||
$guidee = Guide::query()->where("id", "=", $guide->id)->first();
|
||||
$guidee->update($data);
|
||||
$saved = $guidee->save();
|
||||
|
||||
if(!$saved){
|
||||
return Response::detect("guides.update", [ "guide" => $guide ]);
|
||||
}else{
|
||||
$guide = Guide::query()->paginate($request->input("limit", 20));
|
||||
return Response::detect("guides.index", ['guides' => $guide]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Guide $guide
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Guide $guide)
|
||||
{
|
||||
$guide = MenuPlan::find($guide);
|
||||
$guide->delete();
|
||||
return redirect()->route("guides.index");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateGuidesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('guides', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('name');
|
||||
$table->longText('guideArticles');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('guides');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Opret Vejledning
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('guides.create') }}" class="text-white">Opret Vejledning</a> /
|
||||
@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 Vejledning</h1>
|
||||
<form method="post" action="{{ route("guides.store") }}">
|
||||
@csrf
|
||||
<label for="title">Titel på guiden</label>
|
||||
<input type="text" name="name" id="title" required>
|
||||
<textarea name="guideArticles" 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
|
|
@ -0,0 +1,13 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Vejledning - Fjern
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('guides.delete') }}" class="text-white">Fjern Guide</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
@endsection
|
|
@ -0,0 +1,47 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Vejledning - Rediger
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{route('guides.edit', ['guide' => $guide])}}" class="text-white">Rediger vejledning</a> /
|
||||
@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 vejledning:</h1>
|
||||
<form method="post" action="{{route("guides.update", ["guide" => $guide])}}">
|
||||
@csrf
|
||||
@method("PUT")
|
||||
<label for="title">Navn</label>
|
||||
<input value="{{$guide->name}}" type="text" name="name" id="title" required>
|
||||
<label for="editor">Vejledning</label>
|
||||
<textarea name="guideArticles" id="editor">{{$guide->guideArticles}}</textarea>
|
||||
<input type="submit" class="btn btn-dark text-white" value="Rediger">
|
||||
</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
|
|
@ -0,0 +1,38 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Opret Bruger Vejledning
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('guides.index') }}" class="text-white">Opret Vejledning</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
<div class="row align-items-center">
|
||||
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('guides.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Bruger Vejledning</a>
|
||||
</div>
|
||||
<table class="tbl mt-2">
|
||||
<tr>
|
||||
<th>Navn</th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
||||
</tr>
|
||||
@foreach($guides as $guide)
|
||||
<tr>
|
||||
<td>{{$guide->name}}</td>
|
||||
<td><a href="{{ route("guides.edit", [ "guide" => $guide ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><form method="post" action="{{ route("guides.destroy", [ "guide" => $guide ]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
@method("delete")
|
||||
|
||||
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
||||
{{ $guides->links() }}
|
||||
@endsection
|
|
@ -0,0 +1,14 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Vejledning - Opret
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('guides.create') }}" class="text-white">Opret vejledning</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
vejledning blev (ikke) oprettet.
|
||||
@endsection
|
|
@ -0,0 +1,14 @@
|
|||
@extends("admin.layout.base")
|
||||
@extends("admin.layout.header")
|
||||
|
||||
@section("title")
|
||||
Vejledning - Rediger
|
||||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('guides.edit', ["guide" => $link]) }}" class="text-white">Vejledning</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
Din vejledning blev (ikke) redigeret.
|
||||
@endsection
|
|
@ -35,6 +35,9 @@
|
|||
<div class="segment">
|
||||
<h3 class="text-white"><a href="{{ route("contacts.index") }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Kontakter</span></a></h3>
|
||||
</div>
|
||||
<div class="segment">
|
||||
<h3 class="text-white"><a href="{{ route('guides.index') }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Vejledning</span></a></h3>
|
||||
</div>
|
||||
<div class="segment">
|
||||
<h3 class="text-white"><a href="{{ route('feedbacks.index') }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Feedback</span></a></h3>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
@extends("app.layout.base")
|
||||
|
||||
@section("title")
|
||||
Vejledninger
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
<style>
|
||||
h2, h3, h4 {
|
||||
margin-top: 0;
|
||||
}
|
||||
</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->guideArticles !!}
|
||||
<hr class="w-100">
|
||||
@endforeach
|
||||
</main>
|
||||
@endsection
|
|
@ -47,6 +47,10 @@
|
|||
<img src="{{URL::asset('/images/icons/user-hvid.svg')}}" alt="Konto">
|
||||
Konto
|
||||
</a>
|
||||
<a href="{{ route("guides.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/user-hvid.svg')}}" alt="Guide">
|
||||
Vejledning
|
||||
</a>
|
||||
<a href="{{ route('users.logout') }}">
|
||||
<img src="{{URL::asset('/images/icons/Logout.svg')}}" alt="Logud">
|
||||
Log Ud
|
||||
|
|
|
@ -53,3 +53,4 @@ Route::resource("external-links", "ExternalLinkController");
|
|||
Route::resource("resource-extensions", "ResourceExtensionController");
|
||||
Route::resource("resource-categories", "ResourceCategoryController");
|
||||
Route::resource("roles", "RolesController");
|
||||
Route::resource("guides", "GuideController");
|
||||
|
|
Loading…
Reference in New Issue