I need to sort a multidimensional array by date. The data is serialized in a column called prices that contains few values: prices and date. I unserialized this in my controller and I've got $hlisting->prices. I think that this prices is an array and I was to sort all $hlisting by that data value inside prices. (kind $hlisting->prices->date).
That's a code that may be helpful.
<div class="price-dates">
@if(!empty($hlisting->prices))
@foreach($hlisting->prices as $prices)
<div class="price-date">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Period</label>
{!! Form::text('prices_dates[]', $prices['date'], array('class' => 'date-range form-control')) !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Value</label>
{!! Form::text('prices_values[]', $prices['value'], array('class' => 'numeric form-control')) !!}
</div>
</div><!--col-->
<div class="col-sm-1">
<div class="form-group">
<label>Del</label>
<button type="button" class="del-price-date btn btn-sm btn-danger">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
</div><!--row-->
</div>
@endforeach
@else
<div class="price-date">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Period</label>
{!! Form::text('prices_dates[]', NULL, array('class' => 'date-range form-control')) !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Value</label>
{!! Form::text('prices_values[]', NULL, array('class' => 'numeric form-control')) !!}
</div>
</div><!--col-->
</div><!--row-->
</div>
@endif
</div>
I think I should sort it in the controller that send $hlisting to the view.
Thanks