Added Production build.
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\TimePeriod;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TimePeriodController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return view
|
||||
*/
|
||||
public function index(Request $request) : view
|
||||
{
|
||||
$timePeriods = TimePeriod::all();
|
||||
|
||||
return view("timeperiod.index")->with([
|
||||
"timePeriods" => $timePeriods
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view("timeperiod.create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$rawtimeperiod = $request->validate([
|
||||
'name' => 'required|string'
|
||||
]);
|
||||
$timeperiod = new TimePeriod($rawtimeperiod);
|
||||
|
||||
|
||||
if($timeperiod->save()) {
|
||||
return redirect()->route("index");
|
||||
}
|
||||
|
||||
return redirect()->route("error");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param TimePeriod $timePeriod
|
||||
* @return view
|
||||
*/
|
||||
public function show(TimePeriod $timePeriod): View
|
||||
{
|
||||
return view("timeperiod.show-timeperiod",
|
||||
[
|
||||
"timePeriod" => $timePeriod
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param TimePeriod $timePeriod
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(TimePeriod $timePeriod)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TimePeriod $timePeriod
|
||||
* @return View
|
||||
*/
|
||||
public function update(Request $request, TimePeriod $timePeriod) : View
|
||||
{
|
||||
$rawdata = $request->validate([
|
||||
'name' => 'required|string'
|
||||
]);
|
||||
$timePeriod->update($rawdata);
|
||||
|
||||
if(!$timePeriod->save()){
|
||||
return view("timeperiod.show-timeperiod",[
|
||||
'timePeriod' => $timePeriod
|
||||
]);
|
||||
}
|
||||
else{
|
||||
return view("timeperiod.show-timeperiod",[
|
||||
'timePeriod' => $timePeriod,
|
||||
"success" => "Opdaterede Time Period"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param TimePeriod $timePeriod
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(TimePeriod $timePeriod) : RedirectResponse
|
||||
{
|
||||
$timePeriod->post()->delete();
|
||||
|
||||
$timePeriod->delete();
|
||||
return redirect()->route("index");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user