tethys/app/Http/Controllers/Frontend/PagesController.php

58 lines
1.5 KiB
PHP
Raw Normal View History

2018-08-06 12:30:51 +00:00
<?php
2018-09-06 15:58:54 +00:00
namespace App\Http\Controllers\Frontend;
2015-07-19 06:49:24 +00:00
2018-09-06 15:58:54 +00:00
use App\Http\Controllers\Controller;
2018-09-10 13:09:10 +00:00
use App\Models\Dataset;
2018-08-06 12:30:51 +00:00
use Illuminate\View\View;
class PagesController extends Controller
{
public function __construct()
{
// $this->middleware('auth');
}
2018-09-06 15:58:54 +00:00
public function datasets() : View
2018-08-06 12:30:51 +00:00
{
// $books = Book::with('category', 'shelf')->orderByTitle()->get();
$documents = Dataset::orderByType()->get();
2018-09-06 15:58:54 +00:00
return view('frontend.dataset.dataset', compact('documents'));
2018-08-06 12:30:51 +00:00
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id): View
{
2018-11-05 15:44:25 +00:00
$dataset = Dataset::findOrFail($id);
$dataset->load('titles');
$dataset->load('abstracts');
2019-02-14 14:09:11 +00:00
$authors = $dataset->persons()
->wherePivot('role', 'author')
2018-11-05 15:44:25 +00:00
->orderBy('link_documents_persons.sort_order', 'desc')
->get();
2019-02-14 14:09:11 +00:00
$contributors = $dataset->persons()
->wherePivot('role', 'contributor')
2018-11-05 15:44:25 +00:00
->orderBy('link_documents_persons.sort_order', 'desc')
->get();
$submitters = $dataset->persons()
->wherePivot('role', 'submitter')
->orderBy('link_documents_persons.sort_order', 'desc')
->get();
// $authors = $dataset->persons()
// ->wherePivot('role', 'author')
// ->orderBy('link_documents_persons.sort_order', 'desc')
// ->get();
return view('frontend.dataset.show', compact('dataset', 'authors', 'contributors', 'submitters'));
2018-08-06 12:30:51 +00:00
}
2015-07-19 06:49:24 +00:00
}