There is a multidimensional array:
$filter = [ 'trainer' => \Input::get('trainer', null), 'group' => \Input::get('group', null) ]; $club_id = 1; $data = []; for ( $i = 0; $i <= 12; $i++ ) { $row = null; $row = Row::whereRaw( 'club_id = ' . $club_id . ' and row_weight = ' . $i )->first(); if ($row) { $columns = Column::whereRaw( 'row_id = ' . $row->id )->get(); $rowExit = $this->formStubRow(); foreach ( $columns as $column ) { $time = $column->time; $gym = $column->gym; $status = $column->status; $worker_name = Worker::find( $column->worker_id )->worker_name; $service_title = Service::find( $column->service_id )->service_title; $rowExit[ $column->day ][ $gym ] = [ ]; if( ( $filter[ 'trainer' ] != null && $worker_name == $filter[ 'trainer' ] ) || ( $filter[ 'group' ] != null && $service_title == $filter[ 'group' ] ) || ( $filter[ 'trainer' ] == null && $filter[ 'group' ] == null ) ){ $rowExit[ $column->day ][ $gym ] = [ 'time' => $time, 'gym' => $gym, 'group' => $service_title, 'trainer' => $worker_name, 'status' => $status, 'activate' => true ]; } } array_push( $data, $rowExit ); } else { array_push( $data, $this->formStubRow() ); } Log::debug('WTF IS THIS THEN?!!: '.print_r($filter['group'], true)); } return view('pages.services.indexTimetable', compact('filter'), [ 'data' => $data ] ); } Based on it, the table is derived, but I cannot think of how to get closer to editing the object and how to display the data of the trainer and group in the selects.
Tell me, please, how can I substitute variables in order to display the names of groups and trainers in select?
schedule view file:
@extends('basic.main') @section('page_title') Расписание групповых программ @stop @section('content') <div class="container"> <div class="row"> <div class="text-about"> <h3 class="about-title">РАСПИСАНИЕ ГРУППОВЫХ ПРОГРАММ</h3> </div> {!! Form::open(['class' => 'form-inline', 'method' => 'get', 'route' => ['timetable-show']]) !!} <div id="group-select" class="form-group"> {!! Form::label('filter', ' ', ['class' => 'control-label']) !!}<br> {!! Form::select('filter', $filter, ['class' => 'form-control']) !!} </div> <div id="trainer-select" class="form-group"> {!! Form::label('filter', ' ', ['class' => 'control-label']) !!} {!! Form::select('filter', $filter, ['class' => 'form-control']) !!} </div> {!! Form::submit('применить', ['class' => 'btn btn-default']) !!} {!! Form::close() !!} <div id="table-shedule"> <div id="time-days" class='row' style='clear:both;width:1190px;'> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Пн' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Вт' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Ср' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Чт' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Пт' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Сб' }}</p> </div> <div id="shedule-day" class='cell' style='width:169px;float:left;text-align: center;min-height:20px;'> <p>{{ 'Вс' }}</p> </div> </div> @foreach( $data as $row ) <div class='row' style='clear:both;width:1200px;'> @foreach( $row as $day=>$gymArray ) <div class='cell' style='width:170px;float:left;;text-align: center;max-height:370px;overflow: auto'> @foreach( $gymArray as $gym=>$gymInfo ) <div class='gym' style='clear:both'> <p>{{ $gymInfo[ 'time' ] or '' }}</p><hr id="hr-time" style="width:20%"/> <strong id="group-name">{{ $gymInfo[ 'group' ] or '' }}</strong><br> {{ $gymInfo[ 'trainer' ] or '' }}<br> <small id="gym-name">{{ $gym or '' }}</small><br> {{ $gymInfo[ 'status' ] or '' }} </div> @endforeach </div> @endforeach </div> @endforeach </div> </div> </div> @stop