I am using a foreach like below and when I say var_dump from here, 3 values come. I want to add these values to the table from blade.php page, how can I do it?
Controller.php
$videohistories = VideoHistory::where('user_id', $id)
->when(!empty($begin_date), function ($query) use ($int_begin_date) {
$query->where('begin_time', '>=', ($int_begin_date));
})
->when(!empty($int_end_date), function ($query) use ($int_end_date) {
$query->where('begin_time', '<=', $int_end_date);
})
->orderBy('id', 'desc');
//3 values are coming from below foreach
$videohistoriesss = $videohistories->get(['id', 'prop_table']);
foreach ($videohistoriesss as $videohistory) {
$videohistory->total_ticket = DB::table($videohistory->prop_table)->where('to_user_id', $id)->where('video_id', $videohistory->id)->sum('total_ticket');
}
3 values come with var_dump from the videohistoriess foreach
Blade.php
In the foreach below, different data is returning and I want to bring these 3 data in this table.
@foreach ($videohistories as $videohistory)
<tr>
<td>{{ date("Y-m-d H:i:s", $videohistory->create_time) }}</td>
<td>{{ date("Y-m-d H:i:s", $videohistory->end_time) }}</td>
<td>{{ diff_date_format($videohistory->begin_time, $videohistory->end_time, "%H sa %i dk. %s sn") }}</td>
<td>I want to return those 3 data in this part</td>
</tr>
@endforeach
I don't want the first 3 columns in the table in blade.php to change. Only 3 values are returned in the array from the foreach in the controller. I want to return this data in the 4th column of the table.
In your @foreach, you can create the new records.
use App\Models\VideoHistory;
$videoHistory = VideoHistory::create([
'create_time' => $videohistory->create_time,
'end_time' => $videohistory->end_time,
'begin_time' => $videohistory->begin_time,
]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.