fbc

fbc

Member Since 3 Years Ago

Experience Points
5,940
Total
Experience

4,060 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
8
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
5,940 XP
Nov
07
5 days ago
Activity icon

Replied to Passing Data To Mail Controller

OK I adjusted it to:

    public function __construct($orgdata,$userdata,$propertydata,$profiledata,$onboardingdata)
    {
        $this->orgdata = $orgdata;
        $this->userdata = $userdata;
        $this->propertydata = $propertydata;
        $this->profiledata = $profiledata;
        $this->onboardingdata = $onboardingdata;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('New Onboarded User')->view('email.newonboarding');
    }

now I get an error in my blade trying to use:

{{ $onboardingdata[0] }}

Undefined variable: onboardingdata

Activity icon

Started a new Conversation Passing Data To Mail Controller

I created my mail controller like this:

$ php artisan make:mail NewOnboarding

my function in my controller reads this:

        $orgdata = Organization::where('_id',session('org_id'))->get();
        $userdata = User::where('_id',session('user_id'))->get();
        $propertydata = Property::where('_id',session('property_id'))->get();
        $profiledata = Profile::where('_id',session('profile_id'))->get();
        $onboardingdata = OnboardingSurvey::where('_id',session('onboarding_id'))->get();

        Mail::to('[email protected]')->send(new \App\Mail\NewOnboarding($orgdata,$userdata,$propertydata,$profiledata,$onboardingdata));

in \App\Mail\NewOnboarding I added this:

    public function build()
    {
        return $this->subject('New Onboarded User')->view('email.newonboarding',compact('orgdata','userdata','propertydata','profiledata','onboardingdata'));
    }

I get no error but can't seem to use the variables.

Nov
05
1 week ago
Activity icon

Started a new Conversation How Do You Deal With A Data Stream?

My script calls a node.js file that streams values from a sensor every 5 seconds or so. Since it's a constant stream, how do would I go about storing those values in a DB?

$latestrtfeed = shell_exec(node 'path to the script' /company/xxxxx.com/device/sensor/12/3/210/machine/1/value) 
Nov
02
1 week ago
Activity icon

Replied to Laravel Charts To PDF Possible??

How would you make that example work for consoletvs/charts?

Oct
31
1 week ago
Activity icon

Replied to Signature Pad

I'd like to know how to save it! I've been trying to use: https://jsfiddle.net/kevinhorrocks/spv8u56n/2/

but $request->data is always null.

Oct
30
1 week ago
Activity icon

Replied to Laravel Charts To PDF Possible??

It depends on which library you choose to use as some have support for Javascript.

I used barryvdh/laravel-dompdf which has an

isJavascriptEnabled: true (available in config/dompdf.php)

available, but I have not tried it to get my charts working. I had to move on with other things and left this for later. So if you enable Javascript and are able to get it working and showing your charts, please let me know. Or if you decided to do something different, let me know as well. Thanks

Oct
14
4 weeks ago
Activity icon

Replied to How To Loop Through Variables?

hmm, that might be an idea.. let me see if I actually have the skills to pull that off.

Activity icon

Replied to How To Loop Through Variables?

A trait that specifys the survey question like this:

    public function teamsurvey_questions()
    {
        $GW1Q = '1. xxx.';
        $GW2Q = '2. yyy.';
        $GW3Q = '3. yyy.';
...
...
        return [$GW1Q,$GW2Q,$GW3Q,$GW4Q,$GW5Q,$GW6Q,$GW7Q,
            $RES1Q,$RES2Q,$RES3Q,$RES4Q,$RES5Q,$RES6Q,$RES7Q,
            $AUT1Q,$AUT2Q,$AUT3Q,$AUT4Q,$AUT5Q,$AUT6Q,$AUT7Q,
            $CON1Q,$CON2Q,$CON3Q,$CON4Q,$CON5Q,$CON6Q,$CON7Q,
            $EMP1Q,$EMP2Q,$EMP3Q,$EMP4Q,$EMP5Q,$EMP6Q,$EMP7Q];

    }
Activity icon

Started a new Conversation How To Loop Through Variables?

I would like to make a LOOP that replaces a number in variables? Is this possible?? Right now to display every question in a group I use, I do it the manual LONG WAY:

...
                <tr>
                    <td bgcolor="#f5f5dc">{{$GW1Q}}</td>
                    <td style="text-align: center" bgcolor="#dcdcdc">{{$GW1}}</td>
                    <td style="text-align: center" bgcolor="#f08080">{{$GW1std}}</td>
                </tr>
                <tr>
                    <td bgcolor="#f5f5dc">{{$GW2Q}}</td>
                    <td style="text-align: center" bgcolor="#dcdcdc">{{$GW2}}</td>
                    <td style="text-align: center" bgcolor="#f08080">{{$GW2std}}</td>
                </tr>
                <tr>
                    <td bgcolor="#f5f5dc">{{$GW3Q}}</td>
                    <td style="text-align: center" bgcolor="#dcdcdc">{{$GW3}}</td>
                    <td style="text-align: center" bgcolor="#f08080">{{$GW3std}}</td>
                </tr>
...

what I would like to do is something like this:

                @for ($i = 1; $i < 8; $i++)
                    <tr>
                        <td bgcolor="#f5f5dc">{{$GW'.$i.'Q}}</td>
                        <td style="text-align: center" bgcolor="#dcdcdc">{{$GW'.$i.'}}</td>
                        <td style="text-align: center" bgcolor="#f08080">{{$GW'.$i.'std}}</td>
                    </tr>
                @endfor
Oct
10
1 month ago
Activity icon

Replied to Populating An Array From A Database Table Gives Error

Disregard found:

        $OptionsPropertyType = [];
            foreach ($subtypes as $subtype){
                    array_push($OptionsPropertyType,['id' => $subtype->id, 'label' => $subtype->label]);
                }
Activity icon

Started a new Conversation Populating An Array From A Database Table Gives Error

I currently manually populate arrays in my controller. This is very inefficient especially when you want to change a label, you have to go chase it everywhere.

Old style:

        if (session('property_type') == 2) {
            $OptionsPropertyType = array(
                ['id' => '1', 'label' => 'Bank Branch'],
                ['id' => '2', 'label' => 'Financial Office'],
            );
        }

Desired new style:

$subtypes = PropertySubType::where('type_id', session('property_type'))->get();
foreach ($subtypes as $subtype){
       $OptionsPropertyType = Arr::add(['id' => $subtype->id, 'label' => $subtype->label]);
}

Error: Too few arguments to function Illuminate\Support\Arr::add(),

Activity icon

Started a new Conversation Password And Confirmation Validation Problem

I am using: okipa/laravel-bootstrap-components laravelcollective/html

My password form fields look like this:

                    {{ bsPassword()->name('password')->label('Password')->componentHtmlAttributes(['required']) }}
                    {{ bsPassword()->name('password-confirm')->label('Confirm Your Password')->componentHtmlAttributes(['required']) }}

nothing special here....

my controller looks like this:

    public function display_step2(Request $request)
    {
        $request->validate([
            'first_name' => 'required|string|max:255',
            'last_name' => 'required|string|max:255',
            'company' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
            'password-confirm' => 'min:6|same:pass',
//            'g-recaptcha-response' => 'required|captcha', /* disabled for testing */
        ]);

        /* Send Slack notification */
        $client = new Client();
        $client->post('https://hooks.slack.com/services/XXXX', [
            \GuzzleHttp\RequestOptions::JSON => ['text' => 'A new user called ' . $request['name'] . ' at email address '. $request['email'] .' has signed up.']
        ]);

        /* Send Welcome Email */
        Mail::to($request['email'])->send(new \App\Mail\Welcome($request['email']));

       User::create([
            'name' => $request['name'],
            'email' => $request['email'],
            'password' => Hash::make($request['password']),
        ]);


        return route('onboarding.step2');
    }

the errors produced are: The password confirmation does not match. The password-confirm and pass must match.

I can't seem to get past this stage..

Oct
09
1 month ago
Activity icon

Replied to Emailed Password Reset Link Does Not Work

sorry about that.. just added it.

Oct
08
1 month ago
Activity icon

Started a new Conversation Emailed Password Reset Link Does Not Work

These are what my routes look like.

It seems that the link is never hitting the first route with the {token}. It seems to use the second route no matter what. I can comment out the first route and it exhibits the exact same behavior. It just goes back to the Password Reset Request Form.

It's just caught in a loop. It behaves like 'password/reset/{token}' did not exist and ignoring it.

// Password Reset Routes...
Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\[email protected]']);
Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\[email protected]']);
//Route::post('password/email', ['as' => 'password.email', function(){abort(499, 'Function not enabled.');}]);
Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\[email protected]']);
Route::post('password/reset', ['as' => 'password.reset.post', 'uses' => 'Auth\[email protected]']);
|        | POST      | password/email                               | password.email             | App\Http\Controllers\Auth\[email protected]  | web,guest                                            |
|        | GET|HEAD  | password/reset                               | password.reset             | App\Http\Controllers\Auth\[email protected] | web,guest                                            |
|        | POST      | password/reset                               | password.reset.post        | App\Http\Controllers\Auth\[email protected]                | web,guest                                            |
|        | GET|HEAD  | password/reset/{token}                       | password.reset.token       | App\Http\Controllers\Auth\[email protected]        | web,guest      

my NGINX directive looks like this:

location / {
  try_files /public/$uri /public/$uri/ /public/index.php?$query_string;
}

the link is formed as:

https://app.domain.com/password/reset?token=4a944e8bbdf520ecb2ce6def58d21d6dde730a30a0ce22c99183921942474eec&email=john.doe%40gmail.com
Activity icon

Started a new Conversation Plugin To Hide Or Show Form Fields Available??

I was cruising Packagist looking for a plugin that would allow me to hide or display form-fields based on whether others are checked or not. I can't seem to find anything that does it, but then again, I don't know what I'm looking for or how to search for it. Am I looking for a javascript?

Sep
12
2 months ago
Activity icon

Replied to Convert All Fields X In Table To Integer

There are not column types in Mongo DB , yo can store whatever you'd like how you'd like it.

Activity icon

Replied to Convert All Fields X In Table To Integer

wouldn't it be better to just convert to integers all at once? Instead of having to mutate them all the time?? I corrected my STORE() function to:

$newrecord->units_consumed = (int)$request->units_consumed
$newrecord->save();

So that it saves in integer format...

Activity icon

Replied to Convert All Fields X In Table To Integer

yeah, they are numbers stored as strings, I'm trying to convert them back to numbers.

Activity icon

Started a new Conversation Convert All Fields X In Table To Integer

I'm trying to write a script to convert a field in a MongoDB table to an integer. I tried something like this but it does not seem to do anything:

        $bills = BillingData::all();
        foreach ($bills as $bill)
        {
            $bill2 = BillingData::findOrFail($bill->_id);
            $converted = (int)$bill->units_consumed;
            $bill2->units_consumed = (int)$converted;
            $bill2->save();
        }

I get no errors but doesn't seem to do anything.

Activity icon

Replied to Database Intensive Queries Vs CPU Intensive Filtering?

OK Database it is. Thanks.

Activity icon

Started a new Conversation Database Intensive Queries Vs CPU Intensive Filtering?

I was wondering what would be the most efficient way of arriving at the same answer? Here is what I'm using to query values for a chart and adding them to an array:

$daily_realtime_electrical_array = [];
$i=30;
while ($i >= 0){
$reading =  Utility_Meter_Readings::where('property_id', $property_id)->where('resource_type','1')
->where('time','>=',Carbon::now()->startOfDay()->subDay($i)->timestamp)
->where('time','<=',Carbon::now()->endOfDay()->subDay($i)->timestamp)
->pluck('kwh')->sum();
array_push($daily_realtime_electrical_array, $reading);

$i--;
}

should I just be querying the entire 30 days and running queries against that collection? However that would mean more memory to hold the entire collection would be required right?

Sep
11
2 months ago
Activity icon

Replied to Using Service Providers

Thank a bunch!!!! Wow!

Activity icon

Started a new Conversation Using Service Providers

I need to share report creating functionality among my controllers. So I ran:

php artisan make:provider ReportServiceProvider

then I added:

use App\Providers\ReportServiceProvider;

to all the controllers I expected to use it in.

Then I tried various methods to call the functions but failed.

$forecast = ReportServiceProvider::class->get_dark_sky_weather($propdash->lat,$propdash->lng);
$forecast = app(ReportServiceProvider::class)->get_dark_sky_weather($propdash->lat,$propdash->lng);
$forecast = App::make(ReportServiceProvider::class)->get_dark_sky_weather($propdash->lat,$propdash->lng);

I used to use this:

$forecast = $this->get_dark_sky_weather($propdash->lat,$propdash->lng);

when the function was in the same controller. But since I've moved it to the Service Controller I can nolonger access it.

I've tried reading through the Laravel Documentation for Service Providers, but can't seem to make heads or tails of it. Any reference to a working example would be appreciated.

Aug
21
2 months ago
Activity icon

Replied to How To Change "06/01/2018 01" To Epoch Time?

@cronix @mabdullahsari Thanks alot guys!! I found my problem.. the time in the H column was in 12h and not in 24hr... I'm pretty sure that was what was causing my weird date and chart readings. Thanks.

Activity icon

Replied to How To Change "06/01/2018 01" To Epoch Time?

I ended up having to use this because several lines had blank spaces before the dates:

            $reading->time = Carbon::createFromFormat('d/m/Y H', ltrim($data[18]))->timestamp;

Activity icon

Replied to How To Change "06/01/2018 01" To Epoch Time?

something is not right, I'm getting times into 2021 maybe I should be using:

Carbon::createFromFormat('dd/mm/YYYY HH', $data[0])->timestamp

@mabdullahsari @Cronix

Aug
20
2 months ago
Activity icon

Replied to How To Change "06/01/2018 01" To Epoch Time?

yup gonna give that a try soon..thanks!!!!

Activity icon

Replied to How To Change "06/01/2018 01" To Epoch Time?

I need it. It displays the hour.

Aug
19
2 months ago
Activity icon

Started a new Conversation How To Change "06/01/2018 01" To Epoch Time?

I am importing CSV data and the date/time field is formatted kinda weird and come in as:

06/01/2018 01
06/01/2018 02
06/01/2018 03
...

I would like to save this to a date field in a DB in Unix(Epoch)Time format.

Each ends up being $data[0] on the CSV import.

I tried something like:

                $date = date_create($data [0]);
                $reading->time = (int)date_format($date, 'U');

But it does not really work.

The last two digits are the hour. So this is hourly. I have CARBON installed if that is any help.

Thank you in advanced!

Aug
13
2 months ago
Activity icon

Replied to How Do You Filter Results From An Array Without Changing The Structure Of The Array?

It just means that it is an element that I should not use on my charts as it creates weird spikes. I just took care of it though.. I eliminated them at the extraction point.

        /* Pluck just the wattage values to an array */
        $realtime_data_array2 = [];
        foreach ($latestrtfeed['readMeter']['ReadSet']['0']['ReadData'] as $record) {
            /* Skip the bad ones */
            if ($record['Good'] == 0) {
                continue;
            }
            $realtime_data_array2[] = $record['kWh_Tot'];
        }
Activity icon

Started a new Conversation How Do You Filter Results From An Array Without Changing The Structure Of The Array?

I query an API that gives me a results in an array like this: dd($latestrtfeed) give me:

array:1 [▼
  "readMeter" => array:2 [▼
    "Requested" => 1
    "ReadSet" => array:1 [▼
      0 => array:10 [▼
        "Meter" => "350002874"
        "Group" => 65244221
        "Interval" => 60
        "Protocol" => "v4"
        "MAC_Addr" => "xx:xx:xx:00:03:0a"
        "Tz_Offset_Sec" => 0
        "Bad_Reads" => 6
        "Good_Reads" => 994
        "Credits" => 1000000
        "ReadData" => array:1000 [▼
          0 => array:5 [▼
            "Good" => 1
            "Date" => "2019-08-13"
            "Time" => "21:28:04.778"
            "Time_Stamp_UTC_ms" => 1565731684778
            "kWh_Tot" => "8227.50"
          ]
...

the bad_reads throw my charts off.

So I need to filter all ['readMeter']['ReadSet']['0']['ReadData']['Good'] == 0 out of the array.

So I tried using the following query first, to copy all the GOOD reads into a new array but that did not work.

$latestrtfeed2 = $latestrtfeed->where(['readMeter']['ReadSet']['0']['ReadData']['Good'] == 1)->get();

then I tried the foreach below, but could not find the right command to make that happen.

        /* Copy good records to a new array */
        foreach ($latestrtfeed as $record) {
        /* Skip any records which are not good */
            if ($record['ReadSet']['0']['ReadData']['Good'] == 0) {
                continue;
            }
            /* Copy this record to new array */
            $latestrtfeedFiltered[] = $record;
        }

This example I think is the closest I have gotten but I end up with a "Undefined index: Good" error.

Any ideas would be helpful.

Jul
24
3 months ago
Activity icon

Replied to Automatic Sub-domain Creation/handling/routing With Apache Or NGINX

I think I found something that will allow me to write a function:

list($subdomain) = explode('.', Request::server('HTTP_HOST'))

then I could do something like:

$manufacturer = Manufacturer::where('subdomainslug', $subdomain[0])->first();
if (notempty($manufacturer)){
return view('view'.$manufacturer);
}
Activity icon

Started a new Conversation Automatic Sub-domain Creation/handling/routing With Apache Or NGINX

I wanted to create landing pages on subdomains for every product Manufacturer, where only products from that specific manufacturer appears.

main domain = aaa.com & www.aaa.com

manufacturer1 = manufacturer1.aaa.com

manufacturer2 = manufacturer2.aaa.com

etc.etc.etc.

Is there a plugin that allows for this? How would I go setting something like that up? I would assume it will be a special route and Apache or NGINX config.

A google search resulted in packages that are more complicated than what I need, that will switch databases depending on the subdomain,etc.,etc. I just need something simple that says: If you are coming from a *.aaa.com route check for a record in the manufacturer table that matches the subdomain name and open X view file.

Jul
22
3 months ago
Activity icon

Started a new Conversation Design Your Own Chart Plugin Exists??

Is there some kind of a chart addon that will allow the user to build their own chart?

Something where you can specify the data feeds, and the user can click what data they want to chart on each axis? and possibly / ideally be able to download a CSV file of that data?

Jul
13
3 months ago
Activity icon

Replied to Querying Through Several Levels Of Relationships

I think I figured it out:

        $company = Company::find($company->id);
        $users = [];

        foreach ($company->region as $region)
        {
            foreach ($region->department as $department)
            {
                foreach ($department->team as $team)
                {
                    foreach ($team->user as $userteam) {
                            $users [] = $userteam->user;
                    }
                }
            }
        }
Activity icon

Started a new Conversation Querying Through Several Levels Of Relationships

I'm trying to get all the user of a particular company. However a company can have many regions, that can have many departments, that can have many teams and users that can belong to multiple teams.

Relationships are setup as so: App/Company.php

class Company extends Model
{
    public function region() {

        return $this->hasMany('App\Region', 'company_id', 'id');

    }

App/Region.php

class Region extends Model
{
    public function company() {

        return $this->hasOne('App\Company', 'id', 'company_id');

    }
    public function department() {

        return $this->hasMany('App\Department', 'region_id', 'id');

    }

App/Department.php

class Department extends Model
{
    public function region() {
        return $this->hasOne('App\Region', 'id', 'region_id');
    }

    public function team() {
        return $this->hasMany('App\Team', 'department_id', 'id');
    }

App/Team.php

class Team extends Model
{
    public function department() {
        return $this->hasOne('App\Department', 'id', 'department_id');
    }

    public function user() {
        return $this->hasMany('App\UserTeam', 'team_id', 'id');
    }

App/UserTeam.php

class UserTeam extends Model
{
    protected $table = 'userteam';
    public function user() {
        return $this->hasOne('App\User', 'id', 'user_id');
    }
    public function team() {
        return $this->hasOne('App\Team', 'id', 'team_id');
    }

App/User.php

class User extends Authenticatable
{
    public function team() {
        return $this->hasMany('App\UserTeam', 'user_id', 'id');
    }

I had previously taken a stab at it, but it's not really an efficient query and it's not really using the relationships.

        $Regions = Region::where('company_id','=', $company->id)->get();
        foreach ($Regions as $region){
            $Departments = Department::where('region_id','=', $region->id)->get();
            foreach ($Departments as $department){
                $Teams = Team::where('department_id','=', $department->id)->get();
                foreach ($Teams as $team){
                    $Users = User::where('team_id','=', $team->id)->get()->toArray();
                }
            }
        }

        return view('company.edit', compact('company', 'Users'));
Jul
10
4 months ago
Activity icon

Started a new Conversation Error Handling For NGINX BADGATEWAY

My application pulls JSON data from an API like so:

            /* Pull the Feed */
            $monthlyrtfeed = json_decode(file_get_contents(
                'http://xxxx.com?meters=' . $monthly_live_device->feed_id . '&ver=v4&key=' . $monthly_live_device->api_key . '&format=json&report=dy&limit=100&start_date='.$startDayYYYYMMDD.'0000&end_date='.$endDayYYYYMMDD.'0000&fields=Pulse_Cnt_1*'
            ), true);

however the providers API sometimes goes down and I'm left with an ugly error and no continuity.

It would be great if I could figure out how to get it to say something like API is not responding at the moment.

if I try opening the API link directly, I get NGINX BAD GATEWAY. The laravel error I get is:

ErrorException thrown with message "file_get_contents(http://xxx.com/summary?meters=350002879&amp;ver=v4&amp;key=NjUyNDQyMjE6SzhNM1B3cnE&amp;format=json&amp;report=dy&amp;limit=100&amp;start_date=201907010000&amp;end_date=201908010000&amp;fields=kWh_Tot*): failed to open stream: HTTP request failed! "

Stacktrace:
#59 ErrorException in /home/ubuntu/app.com/app/Http/Controllers/PropertyController.php:2318
#58 file_get_contents in /home/ubuntu/app.com/app/Http/Controllers/PropertyController.php:2318
#57 App\Http\Controllers\PropertyController:get_monthly_ekm_elec in /home/ubuntu/app.com/app/Http/Controllers/PropertyController.php:265
#56 App\Http\Controllers\PropertyController:singledash in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#55 call_user_func_array in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#54 Illuminate\Routing\Controller:callAction in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
#53 Illuminate\Routing\ControllerDispatcher:dispatch in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219
#52 Illuminate\Routing\Route:runController in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176
#51 Illuminate\Routing\Route:run in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php:680
#50 Illuminate\Routing\Router:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#49 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
#48 Illuminate\Routing\Middleware\SubstituteBindings:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#47 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#46 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
#45 Illuminate\Auth\Middleware\Authenticate:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#44 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#43 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:75
#42 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#41 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#40 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
#39 Illuminate\View\Middleware\ShareErrorsFromSession:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#38 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#37 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:56
#36 Illuminate\Session\Middleware\StartSession:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#35 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#34 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
#33 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#32 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#31 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
#30 Illuminate\Cookie\Middleware\EncryptCookies:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#29 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#28 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#27 Illuminate\Pipeline\Pipeline:then in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php:682
#26 Illuminate\Routing\Router:runRouteWithinStack in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php:657
#25 Illuminate\Routing\Router:runRoute in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php:623
#24 Illuminate\Routing\Router:dispatchToRoute in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php:612
#23 Illuminate\Routing\Router:dispatch in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
#22 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#21 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:65
#20 Barryvdh\Debugbar\Middleware\InjectDebugbar:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#19 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#18 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/fideloper/proxy/src/TrustProxies.php:57
#17 Fideloper\Proxy\TrustProxies:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#16 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#15 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
#14 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#13 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#12 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
#11 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#9 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
#8 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#7 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#6 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
#5 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#3 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#2 Illuminate\Pipeline\Pipeline:then in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
#1 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /home/ubuntu/app.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
#0 Illuminate\Foundation\Http\Kernel:handle in /home/ubuntu/app.com/public/index.php:55

How could I intercept this error and tell it to display something else ?

Activity icon

Replied to How Do You Add An Element To An Array Without A Key Value?

found it!

  $arr = array("black","blue");
  array_push($arr, "white");
Activity icon

Started a new Conversation How Do You Add An Element To An Array Without A Key Value?

I've been using the ARR helper to get this done but the problem is that I just want to add to the array without having to specify the key value..

$arr = []
$arr = Arr::add($arr,0,'Bob');
$arr = Arr::add($arr,0,'Larry');

only gets me:

array:1 [▼
  0 => "Bob"
]

in order to get Larry I have to do:

$arr = []
$arr = Arr::add($arr,0,'Bob');
$arr = Arr::add($arr,1,'Larry');

So I basically have to number them. i tried append instead of add but it didn't exist. Any other why to get this done??

Activity icon

Replied to Returning Multiple Results Possible When Calling Function Possible?

I can't tell you why this works:

[$one, $two, $three] = test();

but it does... I tried list() though and it works just as well.

Activity icon

Replied to Returning Multiple Results Possible When Calling Function Possible?

I think I solved it with:


[$gas2019consumption_array, $gas2018consumption_array, $gas2017consumption_array, $gas2016consumption_array] = $this->get_billing_gas_data($propertyid);

I don't know if it's functional, but at least it does not give me an error.

Activity icon

Replied to Returning Multiple Results Possible When Calling Function Possible?

the lists() function gives me an error.. I think that could be wrong or something. "Can't use function return value in write context"

Activity icon

Replied to Returning Multiple Results Possible When Calling Function Possible?

what if the variables are array themselves like:

return [$dates, $times];

will it combine them all or mix them together or something?

Activity icon

Started a new Conversation Returning Multiple Results Possible When Calling Function Possible?

Right now I make calls that look like this?

$corrected_date = $this->get_date_correction($a,$b);

and the get_date_correction function ends something like this:

return $corrected_date;

but what about if you want to get multiple results back? Can I do something like this?

$date,$time = $this->parse_feed($feed)

and return multiple results like this?

return $date,$time;
Jul
09
4 months ago
Activity icon

Started a new Conversation Is Extending A Model To Multiple Classes Possible?

To use Mongodb my model needs to have:

...
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class User extends Eloquent
...

my User Model looks like this:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class User extends Authenticatable
{
    use Notifiable, HasApiTokens;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function property() {

        return $this->hasMany('App\Property', 'userid');

    }
}

when I change Authenticatable to Eloquent I get this error:

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in /home/ubuntu/xxx/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 377

when I leave it as Authenticatable, I get this error:

"Call to a member function prepare() on null"

which is normally what happens when I don't include it..

Any ideas how I can make this work?

Jun
29
4 months ago
Activity icon

Replied to How Do You Test If A Variable Is Numeric Or Not?

@CRONIX - I get the same error when trying to test for the existance of the variable. if (!$data[5]){ return view('errors.no-data'); } how would I do that without getting the error?

Activity icon

Replied to How Do You Test If A Variable Is Numeric Or Not?

@CRONIX - yup you are correct.. I uploaded the wrong file.. sorry for the bother, and thank you very much for your help!!

Activity icon

Replied to How Do You Test If A Variable Is Numeric Or Not?

@CRONIX - getting: "Undefined offset: 5" Error with this:

        if (($handle = fopen ( request()->file('file') , 'r' )) !== FALSE) {
            while ( ($data = fgetcsv ( $handle, 1000, ',' )) !== FALSE ) {
                $reading = new Utility_Meter_Readings ();
                $reading->property_id = $request->property_id;
                $reading->utility_id = $request->utility_id;
                $reading->resource_type = $request->resource_type;
                if(is_numeric($data [5])) {
                   //do nothing
                }
                else {
        //skip importing this record
        continue;
        }
                    $date = date_create($data [3]);
                $reading->time = date_format($date, 'U');
                $reading->kwh = $data [5];
                $reading->save ();
            }
            fclose ( $handle );
        }

wondering why $data [5] works fine outside of the if statement.