Hostel Controller for Hostel Service
<?php
namespace App\Http\Controllers;
use App\Hostel;
use Illuminate\Http\Request;
class HostelController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// Using ELOQUONT Way
return Hostel::all();
}
/**
* 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)
{
return Hostel::create($request->all());
}
/**
* Display the specified resource.
*
* @param \App\Hostel $hostel
* @return \Illuminate\Http\Response
*/
public function show(Hostel $hostel)
{
return $hostel;
}
public function showByName($hostelname)
{
return Hostel::all()->where('name', 'LIKE', $hostelname);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Hostel $hostel
* @return \Illuminate\Http\Response
*/
public function edit(Hostel $hostel)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Hostel $hostel
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Hostel $hostel)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Hostel $hostel
* @return \Illuminate\Http\Response
*/
public function destroy(Hostel $hostel)
{
//
}
}