foreach ($titles as $key => $value) {
if($value['id'] == $items[$value['id']]['title-id']){
$titles[$key]['shared'] = $items[$value['id']];
}
}
"headers" => [
"title"=>[
"id" => 3,
"num" => 10,
"str" => 'string',
"parents" =>[ "0" => 4],
],
"title2"=>[
"id" => 5,
"num" => 12,
"str" => 'string2',
"parents" =>[ "0" => 1],
],
"title3"=>[
"id" => 7,
"num" => 13,
"str" => 'string3',
"parents" =>[ "0" => 4],
],
];
// И ВОТ ВТОРОЙ
"items" => [
"item1"=>[
"shared-text" => 'text,
"shared-time" => 10,
"title_id" => 3
],
"item2"=>[
"shared-text" => 'text3,
"shared-time" => 13,
"title_id" => 3
],
"item3"=>[
"shared-text" => 'text7,
"shared-time" => 10,
"title_id" => 7
],
];
// ВОТ МОЯ ПОПЫТКА, НО ОНА НЕ РАБОТАЕТ
foreach ($items as $k => $v) {
foreach ($titles as $key => $value) {
if($value['id'] == $v['title_id']){
$titles [$key]['shared'][] = [$v['shared-text']=>$v['shared-time']];
}
}
}
// ПОЛУЧИТЬ ХОЧУ МАССИВ ВИДА
"headers" => [
"title"=>[
"id" => 3,
"num" => 10,
"str" => 'string',
"parents" =>[ "0" => 4],
"shared" => [ "text" => 10, "text2" => 12]
],
"title2"=>[
"id" => 5,
"num" => 12,
"str" => 'string2',
"parents" =>[ "0" => 1],
"shared" => [ "text4" => 10, "text7" => 12]
],
"title3"=>[
"id" => 7,
"num" => 13,
"str" => 'string3',
"parents" =>[ "0" => 4],
"shared" => [ "text3" => 10, "text5" => 12]
],
];
Route::name('admin.')->prefix('admin')->middleware('auth')->group(function() {
//admin
Route::get('/',['uses' => 'Admin\IndexController@index','as' => 'adminIndex']);
Route::resource('/articles','Admin\ArticlesController');
});
public function edit(Article $article)
{
//
if(Gate::denies('edit',new Article)) {
abort(403);
}
$article->img = json_decode($article->img);
$categories = Category::select(['title','alias','parent_id','id'])->get();
$lists = array();
foreach($categories as $category) {
if($category->parent_id == 0) {
$lists[$category->title] = array();
}
else {
$lists[$categories->where('id',$category->parent_id)->first()->title][$category->id] = $category->title;
}
}
$this->title = ' Редактирование материала - ' .$article->title;
$this->content = view(env('THEME').'.admin.articles_create_content')->with(['categories'=>$lists,'article'=>$article])->render();
return $this->renderOutput();
}