diff --git a/app/Http/Controllers/Frontend/HomeController.php b/app/Http/Controllers/Frontend/HomeController.php index 43323c4..e649b8f 100644 --- a/app/Http/Controllers/Frontend/HomeController.php +++ b/app/Http/Controllers/Frontend/HomeController.php @@ -92,13 +92,12 @@ class HomeController extends Controller /** * show page by $page_slug. */ - public function showPage($slug) + public function showPage($slug): View { // $result = $pages->findBySlug($slug); - if (!is_null(Page::query()->wherePage_slug($slug)->firstOrFail())) { - $result = Page::query()->wherePage_slug($slug)->firstOrFail(); - return view('frontend.pages.index') - ->withpage($result); + if (!is_null(Page::query()->where('page_slug', $slug)->firstOrFail())) { + $result = Page::query()->where('page_slug', $slug)->firstOrFail(); + return view('frontend.pages.index')->withpage($result); } else { throw new GeneralException(trans('exceptions.backend.access.pages.not_found')); } diff --git a/app/Http/Controllers/Settings/CollectionController.php b/app/Http/Controllers/Settings/CollectionController.php index f842fa0..13a11ce 100644 --- a/app/Http/Controllers/Settings/CollectionController.php +++ b/app/Http/Controllers/Settings/CollectionController.php @@ -5,6 +5,8 @@ use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use App\Models\Collection; +use App\Models\CollectionRole; +use App\Http\Requests\Collection\CollectionRequest; class CollectionController extends Controller { @@ -52,12 +54,17 @@ class CollectionController extends Controller /** * Display the specified resource. * - * @param int $id + * @param Collection $collection * @return \Illuminate\Http\Response */ - public function show($id) + public function show(Collection $collection) { - // + $collection = Collection::findOrFail($collection->id); + //get child collections + $collections = $collection + ->children() + ->paginate(10); + return view('settings.collection.collection', compact('collections')); } /** @@ -68,7 +75,9 @@ class CollectionController extends Controller */ public function edit($id) { - // + $collection = Collection::findOrFail($id); + $collectionroles = CollectionRole::pluck('name', 'id'); + return view('settings.collection.edit', compact('collection', 'collectionroles')); } /** @@ -78,9 +87,20 @@ class CollectionController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function update(Request $request, $id) + public function update(CollectionRequest $request, $id) { - // + $collection = Collection::findOrFail($id); + $input = $request->all(); + //$input = $request->except('licenses', 'titles'); + $collection->update($input); + session()->flash('flash_message', 'You have updated the collection "' . $collection->name . '"!'); + if ($collection->parent()->exists()) { + return redirect()->route('settings.collection.show', $collection->parent); + } else { + $test = $collection->collectionrole; + return redirect()->route('settings.collectionrole.show', $collection->collectionrole); + } + //return redirect()->route('settings.collectionrole.index'); } /** diff --git a/app/Http/Controllers/Settings/CollectionRoleController.php b/app/Http/Controllers/Settings/CollectionRoleController.php new file mode 100644 index 0000000..da35945 --- /dev/null +++ b/app/Http/Controllers/Settings/CollectionRoleController.php @@ -0,0 +1,148 @@ +get(); + //$collections = Collection::get(); + $collectionroles = CollectionRole::query() //with('collections') + ->with(['collections' => function ($query) { + $query->whereNull('parent_id'); + }]) + ->get(); + return view('settings.collectionrole.index', compact('collectionroles')); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param CollectionRole $collectionrole + * @return \Illuminate\Http\Response + */ + public function show(CollectionRole $collectionrole) + { + $collectionrole = CollectionRole::findOrFail($collectionrole->id); + //$collections = Collection::query() + $collections = $collectionrole + ->collections() + ->whereNull('parent_id') + // ->where('role_id', '=', $id) + ->paginate(10); + return view('settings.collectionrole.show', compact('collections')); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $collectionrole = CollectionRole::findOrFail($id); + return view('settings.collectionrole.edit', compact('collectionrole')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return RedirectResponse + */ + public function update(Request $request, $id): RedirectResponse + { + $project = CollectionRole::findOrFail($id); + $input = $request->all(); + $project->update($input); + session()->flash('flash_message', 'You have updated the collection role!'); + return redirect()->route('settings.collectionrole.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function delete($id) + { + // + } + + /** + * deactivate author, submitter etc.... + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function hide($id): RedirectResponse + { + $collectionrole = CollectionRole::findOrFail($id); + $collectionrole->update(['visible' => 0]); + session()->flash( + 'flash_message', + 'Visibility of collection role "' . $collectionrole->name . '" has changed successfully.' + ); + return redirect()->route('settings.collectionrole.index'); + } + + /** + * activatew author, submitter etc.... + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function up($id): RedirectResponse + { + // $dateNow = time(); + $collectionrole = CollectionRole::findOrFail($id); + $collectionrole->update(['visible' => 1]); + session()->flash( + 'flash_message', + 'Visibility of collection role "' . $collectionrole->name . '" has changed successfully.' + ); + return redirect()->route('settings.collectionrole.index'); + } +} diff --git a/app/Http/Requests/Collection/CollectionRequest.php b/app/Http/Requests/Collection/CollectionRequest.php new file mode 100644 index 0000000..db233d2 --- /dev/null +++ b/app/Http/Requests/Collection/CollectionRequest.php @@ -0,0 +1,34 @@ +allow('edit-page'); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name' => 'required|max:255', + 'role_id' => 'required', + ]; + } +} diff --git a/app/Http/Requests/PersonRequest.php b/app/Http/Requests/PersonRequest.php index b42a12b..cfb9daf 100644 --- a/app/Http/Requests/PersonRequest.php +++ b/app/Http/Requests/PersonRequest.php @@ -25,7 +25,7 @@ class PersonRequest extends Request return [ 'academic_title' => 'nullable|min:2|max:255', 'last_name' => 'required|min:3|max:255', - 'first_name' => 'nullable|min:3|max:255', + 'first_name' => 'required|min:3|max:255', 'email' => 'nullable|email|max:100', 'identifier_orcid' => 'nullable|min:19|max:50', 'status' => 'required|boolean' diff --git a/app/Http/Requests/ProjectRequest.php b/app/Http/Requests/ProjectRequest.php index 846910a..aa6f6fc 100644 --- a/app/Http/Requests/ProjectRequest.php +++ b/app/Http/Requests/ProjectRequest.php @@ -25,8 +25,8 @@ class ProjectRequest extends Request return [ 'name' => 'required|min:3|max:255', - 'label' => 'required|min:3|max:10' - + 'label' => 'required|min:3|max:10', + 'description' => 'required' ]; } } diff --git a/app/Models/Collection.php b/app/Models/Collection.php index 60edaec..6adf87c 100644 --- a/app/Models/Collection.php +++ b/app/Models/Collection.php @@ -7,9 +7,34 @@ use App\Models\Dataset; class Collection extends Model { + public $timestamps = false; + protected $fillable = [ + 'name', + 'role_id', + ]; public function documents() { return $this->belongsToMany(Dataset::class, 'link_documents_collections', 'collection_id', 'document_id'); } + + #region self join + public function parent() + { + return $this->belongsTo(self::class, 'parent_id'); + } + + public function children() + { + return $this->hasMany(self::class, 'parent_id'); + } + #endregion + + /** + * Get the collection role that the dataset belongs to. + */ + public function collectionrole() + { + return $this->belongsTo(CollectionRole::class, 'role_id', 'id'); + } } diff --git a/app/Models/CollectionRole.php b/app/Models/CollectionRole.php new file mode 100644 index 0000000..0167128 --- /dev/null +++ b/app/Models/CollectionRole.php @@ -0,0 +1,29 @@ +belongsToMany(Dataset::class, 'link_documents_collections', 'role_id', 'document_id'); + // } + + public function collections() + { + //model, foreign key on the Collection model is role_id, local id of this is id + return $this->hasMany(Collection::class, 'role_id', 'id'); + } +} diff --git a/app/Models/Dataset.php b/app/Models/Dataset.php index 42dbb47..700b780 100644 --- a/app/Models/Dataset.php +++ b/app/Models/Dataset.php @@ -62,6 +62,12 @@ class Dataset extends Model ->belongsToMany(Collection::class, 'link_documents_collections', 'document_id', 'collection_id'); } + // public function collectionRoles() + // { + // return $this + // ->belongsToMany(CollectionRole::class, 'link_documents_collections', 'document_id', 'role_id'); + // } + #region [person table] //return all persons attached to this film diff --git a/app/Models/Project.php b/app/Models/Project.php index bfaefa6..6f5d808 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -12,7 +12,7 @@ class Project extends Model // for using $input = $request->all(); //$project = Project::create($input); protected $fillable = [ - 'name', 'label' + 'name', 'label', 'description' ]; diff --git a/composer.lock b/composer.lock index 9ac07d1..8d7cb8b 100755 --- a/composer.lock +++ b/composer.lock @@ -854,26 +854,26 @@ }, { "name": "league/flysystem", - "version": "1.0.46", + "version": "1.0.47", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2" + "reference": "a11e4a75f256bdacf99d20780ce42d3b8272975c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2", - "reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a11e4a75f256bdacf99d20780ce42d3b8272975c", + "reference": "a11e4a75f256bdacf99d20780ce42d3b8272975c", "shasum": "" }, "require": { + "ext-fileinfo": "*", "php": ">=5.5.9" }, "conflict": { "league/flysystem-sftp": "<1.0.6" }, "require-dev": { - "ext-fileinfo": "*", "phpspec/phpspec": "^3.4", "phpunit/phpunit": "^5.7.10" }, @@ -934,7 +934,7 @@ "sftp", "storage" ], - "time": "2018-08-22T07:45:22+00:00" + "time": "2018-09-14T15:30:29+00:00" }, { "name": "monolog/monolog", @@ -1060,16 +1060,16 @@ }, { "name": "nesbot/carbon", - "version": "1.33.0", + "version": "1.34.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "55667c1007a99e82030874b1bb14d24d07108413" + "reference": "1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/55667c1007a99e82030874b1bb14d24d07108413", - "reference": "55667c1007a99e82030874b1bb14d24d07108413", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33", + "reference": "1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33", "shasum": "" }, "require": { @@ -1111,20 +1111,20 @@ "datetime", "time" ], - "time": "2018-08-07T08:39:47+00:00" + "time": "2018-09-20T19:36:25+00:00" }, { "name": "nikic/php-parser", - "version": "v4.0.3", + "version": "v4.0.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d" + "reference": "fa6ee28600d21d49b2b4e1006b48426cec8e579c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd088dc940a418f09cda079a9b5c7c478890fb8d", - "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fa6ee28600d21d49b2b4e1006b48426cec8e579c", + "reference": "fa6ee28600d21d49b2b4e1006b48426cec8e579c", "shasum": "" }, "require": { @@ -1162,7 +1162,7 @@ "parser", "php" ], - "time": "2018-07-15T17:25:16+00:00" + "time": "2018-09-18T07:03:24+00:00" }, { "name": "paragonie/random_compat", @@ -4169,16 +4169,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "628a481780561150481a9ec74709092b9759b3ec" + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/628a481780561150481a9ec74709092b9759b3ec", - "reference": "628a481780561150481a9ec74709092b9759b3ec", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e", + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e", "shasum": "" }, "require": { @@ -4216,7 +4216,7 @@ "phpcs", "standards" ], - "time": "2018-07-26T23:47:18+00:00" + "time": "2018-09-23T23:08:17+00:00" }, { "name": "theseer/tokenizer", diff --git a/public/backend/style.css b/public/backend/style.css index 0fe45d5..5fafcaa 100644 --- a/public/backend/style.css +++ b/public/backend/style.css @@ -475,7 +475,7 @@ a:hover { text-decoration: none; }*/ /*table { width: 100%; margin: 2em 0; }*/ .pure-table a { color: #333; - text-decoration: none; + text-decoration:underline; } .pure-table a:hover { diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index fd7826b..853155d 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -17,7 +17,6 @@ window.Vue = require('vue'); Vue.component('my-vuetable', require('./components/MyVuetable.vue')); - const app = new Vue({ el: '#app' }); \ No newline at end of file diff --git a/resources/views/frontend/sitelink/index.blade.php b/resources/views/frontend/sitelink/index.blade.php index 1cdd62d..6529430 100644 --- a/resources/views/frontend/sitelink/index.blade.php +++ b/resources/views/frontend/sitelink/index.blade.php @@ -1,5 +1,4 @@ -@extends('layouts.app') - +@extends('layouts.app') @section('content')
Collection | -id | +Collection (number of child collections) | +Collection Role | Document id's | Options | @@ -30,8 +30,13 @@ @foreach($collections as $collection)
---|---|---|---|---|---|
{{ $collection->name }} | -{{ $collection->id }} | ++ + {{-- {{ $collection->name }} --}} + {{ $collection->name .' ('. $collection->children->count() .')' }} + + | +{{ $collection->collectionrole->name }} |
@foreach ($collection->documents as $document)
document id: {{ $document->id }} @@ -39,12 +44,8 @@ |
- - - - - - + + {{-- --}} |
Collection | +Count Of Nested Collections | +Options | +Visible | + + + + @foreach($collectionroles as $collectionrole) +
---|---|---|---|
+ + {{ $collectionrole->name .' ('. $collectionrole->collections->count() .')' }} + + | +
+ {{-- @foreach ($collection->documents as $document)
+ document id: {{ $document->id }} + @endforeach --}} + {{ $collectionrole->collections->count() }} + {{-- Show Collections --}} + + |
+ + + {{-- --}} + | ++ @if($collectionrole->visible == 1) + Hide + @else + Unhide + @endif + | +
Collection (number of child collections) | +Collection Role | +Document id's | +Options | + + + + + @foreach($collections as $collection) + +
---|---|---|---|
+ + {{-- {{ $collection->name }} --}} + {{ $collection->name .' ('. $collection->children->count() .')' }} + + | +{{ $collection->collectionrole->name }} | +
+ @foreach ($collection->documents as $document)
+ document id: {{ $document->id }} + @endforeach + + |
+ + + {{-- --}} + | + +