コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $rooms = \montserrat\Room::orderBy('building_id', 'asc', 'name', 'asc')->get();
     foreach ($rooms as $room) {
         $room->building = \montserrat\Location::findOrFail($room->building_id)->name;
     }
     $roomsort = $rooms->sortBy(function ($building) {
         return sprintf('%-12s%s', $building->building, $building->name);
     });
     //dd($rooms);
     return view('rooms.index', compact('roomsort'));
     //
 }