Skip to content

Commit

Permalink
add question modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed May 6, 2024
1 parent 104d062 commit ed4c91f
Show file tree
Hide file tree
Showing 7 changed files with 1,161 additions and 743 deletions.
18 changes: 16 additions & 2 deletions app/Http/Controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,20 +641,34 @@ public function getSublist(Request $request, $key) {
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getFaq(Request $request) {
$tags = Config::get('lorekeeper.faq');
public function getFaq(Request $request, $id = null) {
$tags = config('lorekeeper.faq');
// tags is an array of names, make it so their key is their name also
$tags = array_combine($tags, $tags);
$tags = array_map(function ($tag) {
return ucwords($tag);
}, $tags);
ksort($tags);
return view('browse.faq', [
'id' => $id ?? null,
'faqs' => Faq::visible(Auth::check() ? Auth::user() : null)->orderBy('created_at', 'DESC')->get(),
'tags' => $tags,
]);
}

/**
* Returns a single FAQ question in modal.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getFaqQuestion($id) {
$faq = Faq::visible(Auth::check() ? Auth::user() : null)->find($id);

return view('browse._faq_modal', [
'faq' => $faq,
]);
}

/**
* Returns query for the FAQ page.
*
Expand Down
15 changes: 15 additions & 0 deletions app/Models/Faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ class Faq extends Model {
'answer' => 'required',
];

/**********************************************************************************************
ACCESSORS
**********************************************************************************************/

/**
* Gets the URL of the individual item's page, by ID.
*
* @return string
*/
public function getIdUrlAttribute() {
return url('faq/' . $this->id);
}

/**********************************************************************************************
SCOPES
Expand Down
Loading

0 comments on commit ed4c91f

Please sign in to comment.