@MARVINO - Hey, I don't know how do you have your database structured. Show us your users and transactions table schema so we can help you solve your problem.
@MARVINO - It looks like you already have 1 model with a created at, you can do this:
$rowYouWantToCompareWith = Model::find(1)// you need to define the model you want to compare the date against.
echo $v->created_at->diffInDays($rowYouWantToCompareWith->created_at);
Paste the error code if it is failing.
About comparing 3 or more dates, what do you mean, the dates are compared by sets of 2.
@foreach($documents->transaction as $v)
<tr>
<td>{{$v->created_at}}</td>
<td>{{$v->office->office}}</td>
<td>{{$v->remarks}}</td>
<td>{{$v->status}}</td>
<td>
<?php
$v->o_id = Transaction::find($v->d_id);
// you need to define the model you want to compare the date against.
echo $v->created_at->diffInDays($v->o_id->created_at);
// echo $v->id;
?>
</td>
</tr>
@endforeach
@MARVINO - define the namespace, use App\Transaction instead
@foreach($documents->transaction as $v)
<tr>
<td>{{$v->created_at}}</td>
<td>{{$v->office->office}}</td>
<td>{{$v->remarks}}</td>
<td>{{$v->status}}</td>
<td>
<?php
$v->o_id = App\Transaction::find($v->d_id);
// you need to define the model you want to compare the date against.
echo $v->created_at->diffInDays($v->o_id->created_at);
// echo $v->id;
?>
</td>
</tr>
@endforeach
@MARVINO - If this is always returning 25 this might be that you are not fetching the correct dates to compare, I suggest you to print the 2 dates and see if theyre are the dates that you are expecting.
By the way, you don't need to use the php tags, this code will do the same that you're actual code, but it looks cleaner.
@globals The output should be every row can solve the difference of timestamps, in the code, it happens that you declare the first created_at and it just loops to the next rows, that why the same results i get.
@foreach($documents->transaction as $v)
<tr>
<td>{{$v->created_at}}</td>
<td>{{$v->office->office}}</td>
<td>{{$v->remarks}}</td>
<td>{{$v->status}}</td>
<td>
<?php
$first = App\Transaction::find($v->id);
$second = App\Transaction::find($v->o_id);
echo $first->created_at, $second->created_at; // try to look the output
?>
{{$v->created_at->diffForHumans(App\Transaction::find($v->o_id)->created_at)}}
</td>
</tr>
@endforeach