Began working on more controllers
This commit is contained in:
@@ -4,59 +4,79 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\WashingMachine;
|
||||
|
||||
class WashingMachineController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
$machines = WashingMachine::query()->paginate($request->query("page", 1));
|
||||
|
||||
return view("washing-machine.index", [ "machines" => $machines ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return view("washing-machine.create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$data = $request->validate([
|
||||
"time" => "required"
|
||||
]);
|
||||
|
||||
$machine = new WashingMachine($data);
|
||||
$machine->save();
|
||||
|
||||
return view("washing-machine.store");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
$machine = WashingMachine::find($id);
|
||||
|
||||
return view("washing-machine.show", [
|
||||
"machine" => $machine
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
$machine = WashingMachine::find($id);
|
||||
|
||||
return view("washing-machine.edit", [
|
||||
"machine" => $machine
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,21 +84,36 @@ class WashingMachineController extends Controller
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$data = $request->validate([
|
||||
"time" => "required"
|
||||
]);
|
||||
|
||||
$machine = WashingMachine::find($id);
|
||||
|
||||
$machine->update($data);
|
||||
|
||||
$machine->save();
|
||||
|
||||
return view("washing-machine.edit", [
|
||||
"machine" => $machine
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
$machine = WashingMachine::find($id);
|
||||
$machine->delete();
|
||||
|
||||
return view("washing-machine.destroy");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user