Thursday, March 2, 2017

How to get value of element in the same array when initialize

I Think it's a strange question :

i dont need answer with loop or push to array i'm just wondering about the idea

I'm trying ti initialize an array ,, but i need to read the previous element like this,

return $recourd_list = array(
                'clients'=> array(
                    'route' =>   'clients.index',
                    'title' =>   'fullname',
                    'list'  =>   Clients::orderBy('id', 'desc')->take(5)->get(),
                    'count' =>   Clients::count(),
                    'class' =>   'bgm-lightgreen',
                    'diff'  =>   5 - $recourd_list['clients']['count'],
                    ),

                'sliders'=> array(
                    'route' =>   'sliders',
                    'title' =>   'title',
                    'list'  =>   Sliders::orderBy('id', 'desc')->take(5)->get(),
                    'count' =>   Sliders::count(),
                    'class' =>   'bgm-rightBlue Oil-color',
                    'diff'  =>   5 - $recourd_list['sliders']['count'],
                ),
                'sponsors'=> array(
                    'route' =>   'sponsors.index',
                    'title' =>   'title',
                    'list'  =>   Sponsors::orderBy('id', 'desc')->take(5)->get(),
                    'count' =>   Sponsors::count(),
                    'class' =>   'bgm-nave dark-green',
                    'diff'  =>   5 - $recourd_list['sponsors']['count'],
                    ),
                'packages'=> array(
                    'route' =>   'packages',
                    'title' =>   'title',
                    'list'  =>   Packages::orderBy('id', 'desc')->take(5)->get(),
                    'count' =>   Packages::count(),
                    'class' =>   'bgm-bluegray',
                    'diff'  =>   5 - $recourd_list['packages']['count'],
                    ),
                'event_schedule'=> array(
                    'route' =>   'event_schedule.index',
                    'title' =>   'title',
                    'list'  =>   EventSchedule::orderBy('id', 'desc')->take(5)->get(),
                    'count' =>   EventSchedule::count(),
                    'class' =>   'bgm-orange',
                    'diff'  =>   5 - $recourd_list['event_schedule']['count'],
                    ),
        );

I need to read the count element in diff element .. is that way to do that when initialize array

Thanks All




via moheb hawari

Advertisement