tethys/app/Http/Controllers/Settings/CollectionController.php

117 lines
3.1 KiB
PHP
Raw Normal View History

2018-08-06 12:30:51 +00:00
<?php
2018-08-29 15:18:15 +00:00
namespace App\Http\Controllers\Settings;
2018-08-06 12:30:51 +00:00
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
2018-09-10 13:09:10 +00:00
use App\Models\Collection;
2018-10-04 14:41:29 +00:00
use App\Models\CollectionRole;
use App\Http\Requests\Collection\CollectionRequest;
2018-08-06 12:30:51 +00:00
class CollectionController extends Controller
{
public function __construct()
{
//
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//$collections = Collection::take(10)->get();
//$collections = Collection::get();
$collections = Collection::with('documents')
2018-08-29 15:18:15 +00:00
->paginate(8); //get();
return view('settings.collection.collection', compact('collections'));
2018-08-06 12:30:51 +00:00
}
/**
* 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.
*
2018-10-04 14:41:29 +00:00
* @param Collection $collection
2018-08-06 12:30:51 +00:00
* @return \Illuminate\Http\Response
*/
2018-10-04 14:41:29 +00:00
public function show(Collection $collection)
2018-08-06 12:30:51 +00:00
{
2018-10-04 14:41:29 +00:00
$collection = Collection::findOrFail($collection->id);
//get child collections
$collections = $collection
->children()
->paginate(10);
return view('settings.collection.collection', compact('collections'));
2018-08-06 12:30:51 +00:00
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
2018-10-04 14:41:29 +00:00
$collection = Collection::findOrFail($id);
$collectionroles = CollectionRole::pluck('name', 'id');
return view('settings.collection.edit', compact('collection', 'collectionroles'));
2018-08-06 12:30:51 +00:00
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
2018-10-04 14:41:29 +00:00
public function update(CollectionRequest $request, $id)
2018-08-06 12:30:51 +00:00
{
2018-10-04 14:41:29 +00:00
$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');
2018-08-06 12:30:51 +00:00
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function delete($id)
{
//
}
}