Permalink
Browse files

Website - Show FAQ, track total read and if helpful

  • Loading branch information...
bpocallaghan committed Jul 10, 2017
1 parent cf3b928 commit b74ad65f4a434f76cd1d98e67e2808a4bd171195
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Website;
use App\Models\FAQ;
use App\Models\FaqCategory;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class FAQController extends WebsiteController
{
public function index()
{
$categories = FaqCategory::getAllList();
$items = FaqCategory::with('faqs')->orderBy('name')->get();
return $this->view('faq', compact('items', 'categories'));
}
/**
* Increments the total views
* @param FAQ $faq
* @param string $type
* @return \Illuminate\Http\JsonResponse
*/
public function incrementClick(FAQ $faq, $type = 'total_read')
{
if ($type == 'total_read' || $type == 'helpful_yes' || $type == 'helpful_no') {
$faq->increment($type);
}
return json_response('');
}
}
@@ -17,7 +17,9 @@ public function up()
$table->string('question')->index();
$table->string('slug')->index();
$table->text('answer');
$table->unsignedBigInteger('views')->nullable();
$table->unsignedBigInteger('total_read')->default(0);
$table->unsignedBigInteger('helpful_yes')->default(0);
$table->unsignedBigInteger('helpful_no')->default(0);
$table->unsignedBigInteger('category_id')->index();
$table->unsignedBigInteger('list_order')->nullable();
$table->timestamps();

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,21 @@
#faq-box .faq-category {
font-size: 27px;
margin: 20px 20px 20px 0px;
}
#faq-box .accordion-toggle {
text-decoration: none;
}
#faq-box .panel-heading [data-toggle="collapse"]:after {
font-family: 'FontAwesome';
content: "\f078";
float: right;
color: #337ab7;
font-size: 18px;
line-height: 22px;
}
#faq-box .panel-heading [data-toggle="collapse"].collapsed:after {
color: #454444;
}
@@ -23,7 +23,7 @@
<th>Question</th>
<th>Answer</th>
<th>Category</th>
<th>Total Views</th>
<th>Totals</th>
<th>Updated</th>
<th>Action</th>
</tr>
@@ -34,7 +34,11 @@
<td>{{ $item->question }}</td>
<td>{!! $item->answer_summary !!}</td>
<td>{!! $item->category->name !!}</td>
<td>{!! $item->views !!}</td>
<td>
<span title="Total Reads" data-toggle="tooltip" class="label label-info"><i class="fa fa-eye"></i> {{ $item->total_read }}</span>
<span title="Helpful Yes" data-toggle="tooltip" class="label label-success"><i class="fa fa-thumbs-up"></i> {{ $item->helpful_yes }}</span>
<span title="Helpful No" data-toggle="tooltip" class="label label-danger"><i class="fa fa-thumbs-up"></i> {{ $item->helpful_no }}</span>
</td>
<td>{{ format_date($item->updated_at) }}</td>
<td>{!! action_row($selectedNavigation->url, $item->id, $item->title, ['show', 'edit', 'delete']) !!}</td>
</tr>
@@ -1,44 +1,50 @@
@extends('layouts.admin')
@section('content')
<div class="row">
<div class="col-xs-12">
<div class="box box-primary box-solid">
<div class="box-header with-border">
<h3 class="box-title">
<span><i class="fa fa-table"></i></span>
<span>List All Roles</span>
</h3>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box box-primary box-solid">
<div class="box-header with-border">
<h3 class="box-title">
<span><i class="fa fa-table"></i></span>
<span>List All Roles</span>
</h3>
</div>
<div class="box-body">
<div class="box-body">
@include('admin.partials.info')
@include('admin.partials.info')
@include('admin.partials.toolbar')
@include('admin.partials.toolbar')
<table id="tbl-list" data-server="false" class="dt-table table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Title</th>
<th>Slug</th>
<th>Keyword</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($items as $item)
<tr>
<td><i class="fa fa-{{ $item->icon }}"></i> {{ $item->title }}</td>
<td>{{ $item->slug }}</td>
<td>{{ $item->keyword }}</td>
<td>{!! action_row($selectedNavigation->url, $item->id, $item->title, ['edit', 'delete']) !!}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<table id="tbl-list" data-server="false" class="dt-table table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Title</th>
<th>Slug</th>
<th>Keyword</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($items as $item)
<tr>
<td><i class="fa fa-{{ $item->icon }}"></i> {{ $item->title }}</td>
<td>{{ $item->slug }}</td>
<td>{{ $item->keyword }}</td>
<td>
@if($item->id > 5)
{!! action_row($selectedNavigation->url, $item->id, $item->title, ['edit', 'delete']) !!}
@else
<span class="label label-warning">{{ $item->title }} Role is needed</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@@ -17,7 +17,7 @@
@include('admin.partials.toolbar')
<table id="tbl-list" data-server="false" class="dt-table table nowrap table-striped table-bordered" cellspacing="0" width="100%">
<table id="tbl-list" data-order-by="0|desc" data-server="false" class="dt-table table nowrap table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Version</th>
@@ -22,7 +22,7 @@
<title>{{ isset($HTMLTitle) ? $HTMLTitle : config('app.name') }}</title>
<link rel="stylesheet" href="/css/website.css?v=2">
<link rel="stylesheet" href="/css/website.css?v=3">
@yield('styles')
</head>
@@ -47,7 +47,7 @@
@include('website.partials.popup')
<script type="text/javascript" charset="utf-8" src="/js/website.js?v=2"></script>
<script type="text/javascript" charset="utf-8" src="/js/website.js?v=3"></script>
<script type="text/javascript">
$(document).ready(function ()
{
@@ -0,0 +1,88 @@
@extends('layouts.website')
@section('content')
<div class="panel-group" id="faq-box">
<div id="faq-feedback" class="alert alert-info" role="alert" style="display: none;">
Thank you for your feedback.
</div>
@foreach($items as $category)
<div class="faq-category">{!! $category->name !!}</div>
@foreach($category->faqs as $faq)
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#faq-{{ $faq->id }}">{!! $faq->question !!}</a>
</h4>
</div>
<div id="faq-{{ $faq->id }}" class="panel-collapse collapse" data-id="{{ $faq->id }}">
<div class="panel-body">
{!! $faq->answer !!}
</div>
<div class="panel-footer">
<div class="btn-group btn-group-xs">
<span class="btn">Was this question helpful?</span>
<a class="btn btn-success btn-helpful" href="#" data-id="{{ $faq->id }}" data-type="helpful_yes">
<i class="fa fa-thumbs-up"></i> Yes
</a>
<a class="btn btn-danger btn-helpful" href="#" data-id="{{ $faq->id }}" data-type="helpful_no">
<i class="fa fa-thumbs-down"></i> No
</a>
</div>
</div>
</div>
</div>
@endforeach
@endforeach
</div>
@endsection
@section('scripts')
@parent
<script type="text/javascript" charset="utf-8">
$(function ()
{
$('#faq-box')
.on('show.bs.collapse', function (e)
{
$.ajax({
type: "POST",
url: '/faq/question/' + $(e.target).attr('data-id')
});
$(e.target).parents('.panel').addClass('panel-info');
})
.on('hide.bs.collapse', function (e)
{
$(e.target).parents('.panel').removeClass('panel-info');
});
$('.btn-helpful').on('click', function (e)
{
$.ajax({
type: "POST",
url: '/faq/question/' + $(this).attr('data-id') + '/' + $(this).attr('data-type')
});
showHideAlert();
});
var faqFeedbackTimer = null;
function showHideAlert()
{
if (faqFeedbackTimer) {
clearTimeout(faqFeedbackTimer);
}
$('#faq-feedback').slideDown();
faqFeedbackTimer = setTimeout(function ()
{
$('#faq-feedback').slideUp();
}, 3000);
}
})
</script>
@endsection
@@ -31,6 +31,8 @@
Route::get('/testimonials', 'PagesController@testimonials');
Route::get('/pricing', 'PricingController@index');
Route::get('/faq', 'FAQController@index');
Route::post('/faq/question/{faq}/{type?}', 'FAQController@incrementClick');
});
/*
@@ -36,6 +36,7 @@ if (COMPILE == 'website' || COMPILE == 'all') {
pathCSS + 'vendor/bootstrap.css',
pathCSS + 'vendor/font-awesome.css',
pathCSS + 'app/faq.css',
pathCSS + 'app/testimonials.css',
pathCSS + 'website.css',
], public + '/css/website.css');

0 comments on commit b74ad65

Please sign in to comment.