Notdavis

Notdavis

Member Since 2 Years Ago

Experience Points 860
Experience Level 1

4,140 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 4
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

21 Feb
1 day ago

Notdavis left a reply on Route Conflict With / And A Name-prefix /

How would you domain route without specifying the myapp.com part so it works across local/stage/production?

Notdavis started a new conversation Route Conflict With / And A Name-prefix /

Route::get('/', function () { return view('welcome'); });

Route::name('cars.')->namespace('Users')->middleware('auth')->group(function () { Route::get('/', function () { return view('user.cars.welcome'); }); });

I've tried alternating their order, and I either always get one or the other, what did I miss in the docs?

20 Feb
2 days ago

Notdavis left a reply on Subdomain Routing Question

Of course after posting I find "Route Name Prefixes".

Notdavis started a new conversation Subdomain Routing Question

I've read the docs (5.7) on how you can use Route::domain('{account}.myapp.com')-> to route dynamic subdomains to controllers.

What I would to do is route cars.myapp.com to a specific set of routes, with separate root / paths and all the rest, in addition, I would like myapp.com to be replaced with the apps URL so that it works with localhost as well as in production [host file is setup for the subdomain].

Right now I am trying Route::domain('cars.' . env('APP_URL'))-> but that doesn't seem to work, I get taken to the apps default / and all the rest.

11 Feb
1 week ago

Notdavis left a reply on __CONSTRUCT Passed As Method In $request->method(); ?

Snapey, that is very very possible, I log a lot of attempts to reach wp-logins and PhpMyAdmins.

I want to be thorough to ensure Laravel isn't vulnerable / I missed something about middleware

Notdavis left a reply on __CONSTRUCT Passed As Method In $request->method(); ?

VPN Simplifier

Home » IP Tools » IP Lookup » 120.79.73.22 IP Details for 120.79.73.22 Share details about this IP address This information should not be used for emergency purposes, trying to find someone's exact physical address, or other purposes that would require 100% accuracy.

120.79.73.22

Details for 120.79.73.22 IP: 120.79.73.22 Decimal: 2018461974 Hostname: 120.79.73.22 ASN: 37963 ISP: Aliyun Computing Co. Organization: Hangzhou Alibaba Advertising Co.,Ltd. Services: None detected Type: Broadband Assignment: Static IP Blacklist: Continent: Asia Country: China cn flag Latitude: 34.7725 (34° 46′ 21.00″ N) Longitude: 113.7266 (113° 43′ 35.76″ E)

Notdavis left a reply on __CONSTRUCT Passed As Method In $request->method(); ?

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'method' at row 1 #33 vendor/laravel/framework/src/Illuminate/Database/Connection.php(458): execute #32 vendor/laravel/framework/src/Illuminate/Database/Connection.php(458): Illuminate\Database{closure} #31 vendor/laravel/framework/src/Illuminate/Database/Connection.php(657): runQueryCallback #30 vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): run #29 vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): statement #28 vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): insert #27 vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): processInsertGetId #26 vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2202): insertGetId #25 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1285): __call #24 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(726): insertAndSetId #23 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(691): performInsert #22 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(554): save #21 app/Http/Middleware/LogHttp.php(38): handle #20 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #19 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #18 vendor/fideloper/proxy/src/TrustProxies.php(57): handle #17 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #16 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #15 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): handle #14 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #13 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #12 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): handle #11 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #10 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #9 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): handle #8 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #7 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #6 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): handle #5 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #4 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #3 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): then #2 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): sendRequestThroughRouter #1 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): handle #0 public/index.php(55): null Illuminate\Database\QueryException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'method' at row 1 (SQL: insert into http_logs (ipv4, method, path, query, ajax, datetime) values (120.79.73.22, __CONSTRUCT, /, , 0, 2019-02-10 19:07:51)) #31 vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): runQueryCallback #30 vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): run #29 vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): statement #28 vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): insert #27 vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): processInsertGetId #26 vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2202): insertGetId #25 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1285): __call #24 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(726): insertAndSetId #23 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(691): performInsert #22 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(554): save #21 app/Http/Middleware/LogHttp.php(38): handle #20 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #19 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #18 vendor/fideloper/proxy/src/TrustProxies.php(57): handle #17 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #16 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #15 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): handle #14 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #13 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #12 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): handle #11 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #10 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #9 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): handle #8 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #7 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #6 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): handle #5 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Pipeline{closure} #4 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing{closure} #3 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): then #2 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): sendRequestThroughRouter #1 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): handle #0 public/index.php(55): null

Notdavis started a new conversation __CONSTRUCT Passed As Method In $request->method(); ?

I have middleware which logs data for me. In the kernel.php it's the last index of the protected $middleware array.

It's been running now for a year+, without issue, however recently it has thrown an error which leads back to $request->method(); returning the string __CONSTRUCT

IP logged is our own IP as well.

I'm going to review any changes we made, to see if I can track what's causing this, but anyone familiar with middleware knowing what and when might cause this?

I have created another controller which I am using and calling methods off it within itself, I don't recall doing anything with the constructor of that class but again, will go through my changes.

Thanks in advance

laravel 5.7 php 7.1.17

25 Jan
4 weeks ago

Notdavis left a reply on ImageMagick For Laravel Project

spatie/pdf-to-image requires ImageMagic

04 Oct
4 months ago

Notdavis left a reply on Select Users That Have Only 1 Role

staudenmeir, that was the trick. Didn't know you could do that with has and relationships.

Notdavis left a reply on Select Users That Have Only 1 Role

Users have many roles, but I want to those who only have TheRoleName. Other Users will have multiple roles, which could include TheRoleName.

Nakov, I have tried ->whereNotIn('id', $array_of_notTheRoleName_ids)

Notdavis left a reply on Select Users That Have Only 1 Role

Too early, !coffee, fixing above Users to belongsToMany

Notdavis started a new conversation Select Users That Have Only 1 Role

I have the classic setup of Users and Roles, where Users can have many Roles, and Roles belong to many Users:

    {
        return $this->belongsToMany('App\Models\Role')->withTimestamps();
    }
    {
        return $this->belongsToMany('App\Models\User');
    }

Currently it's easy to generate a list of users where they have a Role, e.g.

            $query->where('name', 'TheRoleName');
})->paginate(50);

But I want to limit Users I send to a view to Users who have only 'TheRoleName' and don't also belong to 'AnotherRoleName', and it's become a little complicated.

I have tried Role::with('users')->where('name', 'TheRoleName')->get() but haven't quite worked out how to get a collection of Users from that to send to the view which uses methods on the Users model

06 Mar
11 months ago

Notdavis left a reply on Return Response->json($array) Returns Integers And Floats As "Strings"

Thank you, I will assume from here on in, Query Builder returns values ignorant of $casts and types. However, I still don't know why the first value was converted to an int while the rest was with the data returned from the Query Builder, even when I renamed it form Id to Ralph.

In terms of why Query Builder, I'm used to writing SQL queries, and was doing so before moving to Laravel and I am learning Eloquent. I've also read Query Builder is a lot faster than Eloquent once you start joining multiple tables?

In terms of the select, this is part of a controller that returns only these values, and so I don't need the rest of the columns on all four tables that make up the join.

05 Mar
11 months ago

Notdavis left a reply on Return Response->json($array) Returns Integers And Floats As "Strings"

Sure, here is the query:

  $claimUpdates = DB::table('submitted_claims')
            ->join('claims', 'claims.id', '=', 'submitted_claims.claim_id')
            ->join('patients', 'patients.id', '=', 'claims.patient_id')
            ->join('submissions', 'submissions.id', '=', 'submitted_claims.submission_id')
            ->select('submissions.updated_at', 'submitted_claims.claim_id as id', 'submitted_claims.action', 'submitted_claims.paid', 'submitted_claims.message',
                    'submitted_claims.action_message', 'patients.last_name', 'patients.given_name', 'submitted_claims.accounting_num',
                    'submitted_claims.amount_paid','submitted_claims.paid_date','submitted_claims.recreate','submitted_claims.service_dates')
            ->where([
                ['claims.user_id', '=', $user->id],
                ['submissions.updated', '=', '1']
            ])
            ->get();

And as mentioned, on the SubmittedClaim model, the values I would like as Integers and Floats are in the protected $casts array, e.g.

protected $casts = ['batch_date' => 'date', 'paid_date' => 'date', 'recreate' => 'integer', 'paid' => 'integer', 'amount_paid' => 'float', 'action' => 'integer'];

Do the cast values types get applied to values returned from Query Builder?

Notdavis left a reply on Return Response->json($array) Returns Integers And Floats As "Strings"

Thanks for trying rumm.an, but it looks as if you didn't fully read the issue.

I've solved it for now using intval & floatval.

My question is, is this a possibility with Query Builder? Or if I go that route the onus is on me to make sure my ints are ints etc?

The wildcard is that first value int'n properly.

04 Mar
11 months ago

Notdavis left a reply on Return Response->json($array) Returns Integers And Floats As "Strings"

Late night mistake on my part. I was testing with 1 result, and I was interating over the returned rows, I was thinking I was interating over the columns. d'oh.

is_numeric and intval are now working.

In terms of query builder then, there is no easy way to cast values?

Notdavis started a new conversation Return Response->json($array) Returns Integers And Floats As "Strings"

Array is created from a DB::table query, and oddly the first value, id, isn't converted, all the rest are. I thought it might have something to do with the name so I tried changing it to ralph to see, and it still comes through as an int.

I've got my columns cast as integers, and even made sure the table in the DB::table is the one used by model with the casts. However, I'm not sure that matters as the values pass through a foreach loop and are assigned to another vanilla array.

In the foreach I've even tried is_numeric to intval() and that doesn't work.

The one thing that does work is encoding it to json with JSON_NUMERIC_CHECK then decoding, then passing it to response->json() to have it encoded again :

          $response = json_encode(array('status' => 'success', 'data' => $response),    JSON_NUMERIC_CHECK);
            $response = json_decode($response);

            return response()->json($response);

What did I miss?

03 Mar
11 months ago

Notdavis left a reply on Call To Undefined Method Illuminate\\Database\\Query\\Builder But Method Exists

This is the query I am trying to replicate with Eloquent, ideally returning a collection of SubmittedClaim models to then chain off to other additional tables to retrieve data.

     $claimUpdates = DB::table('claims')
       ->join('submitted_claims', 'claims.id', '=', 'submitted_claims.claim_id')
       ->join('submissions', 'submissions.id', '=', 'submitted_claims.submission_id')
       ->select('submitted_claims.id','submissions.updated')
       ->where([
           ['claims.user_id', '=', $user->id],
           ['submissions.updated', '=', '1']
       ])
       ->get();

Notdavis left a reply on Call To Undefined Method Illuminate\\Database\\Query\\Builder But Method Exists

Yes, the update column is on the submission table.

$user->claims->submittedClaim->submission()->where('update', '=', 1)->get();

The above results in the following error: Property [submittedClaim] does not exist on this collection instance.

I think I missed the Laravel docs which cover $user->claim->submittedClaim()->get() vs $user->claim()->submittedClaim()->get()

If if anyone knows what it is I should read up on so I could get a firmer understanding?

02 Mar
11 months ago

Notdavis left a reply on Call To Undefined Method Illuminate\\Database\\Query\\Builder But Method Exists

Yes, however for the sake of post, there is actually a 4th model called Submissions which has a hasMany submittedClaims and on the SubmittedClaim model there is a belongsTo Submissions.

It's on the Submissions that the update exists.

So the actually query is

$user->claims()->submittedClaim()->submission()->where('update', '=', 1)->get();

I thought for prototyping, you could chain the Models together? Did this used to be a thing in older versions?

Notdavis started a new conversation Call To Undefined Method Illuminate\\Database\\Query\\Builder But Method Exists

I can't figure out what I am missing, but I'm sure it will be something very obvious.

Models:

` class User extends Authenticatable { ... public function claims() { return $this->hasMany('App\Models\Claim'); } }

class Claim extends Model { ... user_id ... public function user() { return $this->belongsTo('App\Models\User'); } public function submittedClaim() { return $this->hasOne('App\Models\SubmittedClaim'); } }

class SubmittedClaim extends Model { ... claim_id ... public function Claim() { return $this->belongsTo('App\Models\Claim'); } } `

Code: $user = Auth::user(); $user->claims()->submittedClaim()->where('update', '=', 1)->get();

Error: Call to undefined method Illuminate\\Database\\Query\\Builder::submittedClaim()