tethys/app/Http/Controllers/ShelfController.php

71 lines
1.5 KiB
PHP
Raw Normal View History

2018-08-06 12:30:51 +00:00
<?php
namespace App\Http\Controllers;
2015-07-19 06:49:24 +00:00
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Shelf;
use App\Http\Requests\ShelfRequest;
use Illuminate\Http\Request;
2018-08-06 12:30:51 +00:00
class ShelfController extends Controller
{
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function __construct()
{
$this->middleware('auth');
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function index()
{
$shelves = Shelf::get();
return view('lms.settings.shelf.shelf', compact('shelves'));
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function add()
{
return view('lms.settings.shelf.add');
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function store(ShelfRequest $request)
{
$input = $request->all();
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
$shelf = Shelf::create($input);
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
//flash messaging
session()->flash('flash_message', 'You have been added 1 shelf!');
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
return redirect()->route('settings.shelf');
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function edit($id)
{
$shelf = Shelf::findOrFail($id);
return view('lms.settings.shelf.edit', compact('shelf'));
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function update($id, ShelfRequest $request)
{
$shelf = Shelf::findOrFail($id);
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
$input = $request->all();
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
$shelf->update($input);
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
session()->flash('flash_message', 'You have been updated 1 shelf!');
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
return redirect()->route('settings.shelf');
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
public function delete($id)
{
$shelf = Shelf::findOrFail($id);
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
$shelf->delete();
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
session()->flash('flash_message', 'You have been deleted 1 shelf!');
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
return redirect()->route('settings.shelf');
}
2015-07-19 06:49:24 +00:00
}