When I trying' to get value from database using aliases "as", I got an error like this :
at HandleExceptions->handleError(8, 'Undefined offset: 0', '/data/gui/hum/hum.v3.1/vendor/laravel/framework/src/Illuminate/Support/Collection.php', 1570, array('key' => 0))
I tried to change the data stored in the temporary variable to array. I use method from laravel "collect()" to collect data in the form of objects.
This is my function to get data and return view for get data usage from database.
$dtusagearray = DB::select(DB::raw(" select
sum.msisdn msi,
sum.imsi ims,
sum.customer_status st,
sum.grapari_name grp,
substr(sum.customer_group,1,3) cg,
sum.regional_name reg,
sum.billperiod eop,
sum.totalcharge tch,
to_char(sum.totalcharge,'999,999,999,999') tc,
to_char(sum.riskscore,'999,999,999,999') cr,
to_char(sum.billingavg,'999,999,999,999') avb,
to_char(sum.billingmax,'999,999,999,999') mab,
to_number(to_char(sum.lastcall,'DD')) day,
to_char(ceil(sum.billingavg/(ceil(to_number(to_char(sum.lastcall,'DD'))))),'999,999,999,999') avchday,
to_char(sum.lastcall,'dd/mm/yyyy hh24:mm:ss') lc,
(select count(msisdn) from actions a where a.msisdn=sum.msisdn and a.billperiod=sum.billperiod and a.actiontype='5') jml_call,
(select count(msisdn) from actions a where a.msisdn=sum.msisdn and a.billperiod=sum.billperiod and a.actiontype='3') jml_sms,
(select count(msisdn) from actions a where a.msisdn=sum.msisdn and a.billperiod=sum.billperiod and a.actiontype='2') jml_adj,
(select count(msisdn) from actions a where a.msisdn=sum.msisdn and a.billperiod=sum.billperiod and a.actiontype='1') jml_blk,
nvl(sum.roam_name, sum.lastroam) lr
from master_ip333_charge sum
where sum.msisdn = '62'||'$msisdn'
order by sum.billperiod asc
And this is how I trying' to convert data from object and return view for show the result
$dtusagearray = collect($dtusagearray);
$dtusage = $dtusagearray[0];
return view('customerprofile', compact('dtusage'));
The output of this function is to display customer usage data, based on the results of the calculation of the queries.