public function showJobCategoryContent($id)
{
$jobsInfoById = DB::table('jobs')->where('category_id', '=', $id)->where('published', '=', 1)->paginate(3);
$jobsInfoById = $jobsInfoById->map(function ($job) {
return [
'created_at' => Carbon::parse($job->created_at)->addDays(30)->toDateTimeString()
];
});
$dates = [];
$dates[] = $jobsInfoById->pluck('created_at');
$jobsInfosById = [];
$jobsInfosById[] = DB::table('jobs')->where('category_id', '=', $id)->where('published', '=', 1)->paginate(3);
return view('front.category-content.job-category-content',[
'jobsInfosById'=> $jobsInfosById,
'dates'=>$dates
]);
}
Как использовать эти два массива в цикле
Моя страница просмотра:
@php
$arrayData = array_merge($jobsInfosById, $dates);
@endphp
@foreach($arrayData as $jobInfoById)
[*]
{{$jobInfoById->company_name}}
Deadline:{{ date('d F, Y', strtotime($jobInfoById->date)) }}[/b]@endforeach
Отображается ошибка:
Неопределенное свойство: Illuminate\Pagination\LengthAwarePaginator::$company_name
$arrayData значение следующее:
Array
(
[0] => Illuminate\Pagination\LengthAwarePaginator Object
(
[total:protected] => 3
[lastPage:protected] => 1
[items:protected] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[id] => 3
[company_name] => Khulan Computer house
[published] => 1
[created_at] => 2017-10-22 15:25:54
[updated_at] => 2017-10-24 11:00:52
)
[1] => stdClass Object
(
[id] => 4
[company_name] => Khulan Computer house
[published] => 1
[created_at] => 2017-10-22 15:46:44
[updated_at] => 2017-10-24 11:00:41
)
[2] => stdClass Object
(
[id] => 11
[company_name] => Computer Lab
[published] => 1
[created_at] => 2017-10-24 08:01:00
[updated_at] => 2017-10-24 10:53:57
)
)
)
[perPage:protected] => 3
[currentPage:protected] => 1
[path:protected] => http://localhost/jobs-zone/public/categ ... -content/4
[query:protected] => Array
(
)
[fragment:protected] =>
[pageName:protected] => page
)
[1] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => 2017-11-21 15:25:54
[1] => 2017-11-21 15:46:44
[2] => 2017-11-23 08:01:00
)
)
)
Подробнее здесь: https://stackoverflow.com/questions/473 ... lt-in-view