File: /home/mmickelson/spilicensing/app/Http/Controllers/HistoryController.php
<?php
namespace App\Http\Controllers;
use App\ActivityType;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\History;
use App\License;
use App\System;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Session;
class HistoryController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$history = History::paginate(15);
return view('history.index', compact('history'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$activitytype = ActivityType::lists('activityType', 'id');
$license = License::lists('licenseKey', 'id');
$system = System::lists('systemId', 'id');
return view('history.create', compact('activitytype', 'license', 'system'));
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
History::create($request->all());
Session::flash('flash_message', 'History added!');
return redirect('history');
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$history = History::findOrFail($id);
return view('history.show', compact('history'));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
$history = History::findOrFail($id);
$activitytype = ActivityType::lists('activityType', 'id');
$license = License::lists('licenseKey', 'id');
$system = System::lists('systemId', 'id');
return view('history.edit', compact('history', 'activitytype', 'license', 'system'));
}
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return Response
*/
public function update($id, Request $request)
{
$history = History::findOrFail($id);
$history->update($request->all());
Session::flash('flash_message', 'History updated!');
return redirect('history');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
History::destroy($id);
Session::flash('flash_message', 'History deleted!');
return redirect('history');
}
}