Bvanhaastrecht

Bvanhaastrecht

Member Since 1 Year Ago

Experience Points
1,330
Total
Experience

3,670 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 1
1,330 XP
Sep
16
1 month ago
Activity icon

Replied to Nested Resource Route Without ID

@newbie360, yes this works very well!

I can even apply this when I go nested on 'horror':

Route::resource('movies.horror.ratings',    'HorrorController')->parameter('movies', 'rating');

Be warned, you must use a single name for the second parameter or it doenst work.

Thank you very much!

Activity icon

Replied to Nested Resource Route Without ID

No worries, appriciate the help!

This gives an error:

BadMethodCallException: Method Illuminate\Routing\PendingResourceRegistration::where does not exist. in file xxxx\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php on line 103

Does resource routes support the where method?

Activity icon

Replied to Nested Resource Route Without ID

@newbie360,

With the regex example, I would like to put each movie type (horror|adventure|sci-fi) into a seperate controller.

/group/{groupId}/users/{userId}/movies/horror  => HorrorController
/group/{groupId}/users/{userId}/movies/adventure => AdventureController
/group/{groupId}/users/{userId}/movies/sci-fi => Sci-FiController

But it seems likea resource route doent have the feature I'm looking for. So I think I need to go for a custom route, unless someone has an idea.

Sep
15
1 month ago
Activity icon

Replied to Nested Resource Route Without ID

@automica, I use resource routes not normal routes.

So my resource route definition looks like:

Route::resource('group.users.movies', MoviesController');

Which generates the id sections automaticly:

/group/{groupId}/users/{userId}/movies/{movieId}

But now I would like to make the last part movies not use id's. So i tried:

Route::resource('group.users.movies/horror', 'HorrorControllerController');
Route::resource('group.users.movies/adventure', 'AdventureControllerController');
Route::resource('group.users.movies/sci-fi', 'SciFiControllerController');

This unfortunately doesnt work. Gives 404 on:

/group/<groupId>/users/<userId>/movies/horror
Activity icon

Started a new Conversation Nested Resource Route Without ID

Hello,

We are very happy with nested resource routes, but I'm unable to accomplish the following.

Say we have the following url structure:

/group/<groupId>/users/<userId>/movies/horror
/group/<groupId>/users/<userId>/movies/adventure
/group/<groupId>/users/<userId>/movies/sci-fi

From the /movies part we do not want to use ID's. So we need to tell the route to not require an id.

Is there a way to accomplish this.

(ps, the above structure is just an example of what we are trying to accomplish.)

Kind regards, Bastiaan

Jul
03
3 months ago
Activity icon

Replied to Set Variable Within A Model Class

No luck with scoping. It doesn't allow me to change the data / attributes.

My DB has these fields:

count
price

Data is stored as:

count = 30
price = 5

or

count = 10
price = -67

For some graphs I need to the data different, it cant handle negative prices. So therefore I sometimes need the output of the model to be:

count = -10
price = 67

So I need to find a way to manipulate the attribute as data flows thru it. So therefore my accessor changes it, this works. But I need external outside the model to be able to control it.

Activity icon

Replied to Set Variable Within A Model Class

Local scopes looks promising, I will look into this and report back. Thanks.

Activity icon

Replied to Set Variable Within A Model Class

No, `noNegative' will eventueally be settable. So I can control the Models output from outside the model.

Jul
02
3 months ago
Activity icon

Replied to Set Variable Within A Model Class

Anyone please?

Activity icon

Replied to Nested Relation Pull Child To Parent

How simple, yes you are absolutely right. Just add the relations and query from customers. I was thinking way to complex. Thanks!

Jul
01
3 months ago
Activity icon

Started a new Conversation Nested Relation Pull Child To Parent

Hello,

I have a model/DB design as following:

Customer -> Invoice -> InvoiceItem -> Contract

Customer has many invoices, Invoice has many InvoiceItem, and an InvoiceItem has one contract.

I would like to get the data like this:

Customer -> Contract -> InvoiceItem

I can do this with stupid separate gets, and loop thru the data's. But would like to be it an eloquent way of getting this data.

Help is very much appreciated.

Kind regards, Bastiaan

Jun
30
3 months ago
Activity icon

Started a new Conversation Set Variable Within A Model Class

Hello,

I have a model which I would like to change an attribute output based on a public variable within the model. This so I can control the models output from a parent call.

And to make it more complicated. The model is used in a relation, so need to set the public variable from the parent model.

model

class CustomerInvoices extends Model
{
    public function invoiceItemsDetails()
    {
        return $this->hasMany('App\Models\CustomerInvoiceItems', 'run_uuid', 'run_uuid');
    }
}

relation model

class CustomerInvoiceItems extends Model
{
    public $noNegative = false; 

    public function getCountAttribute($value)
    {
        if ($this->noNegative) {
            if (\App\Models\BillingItems::find($this->item)->type_discount == 1) {
                return (int) (-1 * abs($value));
            }
        }

        return $value;
    }
}

query / attempt to set the public variable

$invoices = \App\Models\CustomerInvoices::with([
            'invoiceItemsDetails' => function ($query) {
                $query->noNegative = true;
            },
);

But this doesnt work. Any idea how I could do this, or is my apprough a bit off. Any help is very welcome.

Kind regards, Bastiaan

Jun
11
4 months ago
Activity icon

Awarded Best Reply on Unable To Retrieve Request Body With POST Method

Got it, using trailing slash I get no body, with no trailing slash it works.

Works:

POST https://url/api

No body:

POST https://url/api/

Is this as expected?

May
27
4 months ago
Activity icon

Awarded Best Reply on Worker Crashes When Timeout Is Hit (windows)

In windows, the worker stops when his timeout is reached. There's no auto restart which is availeble in Linux.

My current solution is to give each job a public $timeout = <seconds> which is less then the worker service timeout. This avoids the service to crash.

Activity icon

Replied to Composer Runs On @includes

Ok understand, we will create a filter for unwanted views. Thanks!

Activity icon

Replied to Worker Crashes When Timeout Is Hit (windows)

In windows, the worker stops when his timeout is reached. There's no auto restart which is availeble in Linux.

My current solution is to give each job a public $timeout = <seconds> which is less then the worker service timeout. This avoids the service to crash.

Activity icon

Replied to Composer Runs On @includes

Aditionally, is the data cached in the individual composer runs, or does every blade & composer touch the backed database?

Activity icon

Replied to Composer Runs On @includes

Ah, so this is v7 behaviour. We recently upgraded to v7 and noticed this. The inheritance is still in place?

There's no parameter you can give the @includes to exclude him from the composer?

May
26
4 months ago
Activity icon

Started a new Conversation Composer Runs On @includes

We noticed that our wildcard composer also fires on blade includes. This seem not logical as the @includes inherit the variables from the parent blade. This seems to add additional load which we would like to eliminate.

Is this by design and can we exclude the blade @includes from the composer service?

May
25
4 months ago
Activity icon

Started a new Conversation Worker Crashes When Timeout Is Hit (windows)

Hello,

We run laravel 7 app's on a Windows 2016 IIS box. We have noumerous jobs and 4 queue's with various priority's. All DB based.

Most of our jobs finish within 60 seconds, but we have some long jobs up to 30 minutes. Those long jobs have the `public $timeout' set.

However when a job with no custom timeout exceeds the worker timeout, the worker crashes.

Worker: `artisan queue:listen --queue=jobs --tries=1 --timeout=300'

The crash: The process "php.exe" artisan queue:work --once --queue=jobs --delay=0 --memory=128 --sleep=3 --tries=1" exceeded the timeout of 300 seconds.

Is it expected behaviour the worker crashes completely? Should only that particular child worker crash?

Kind regards, Bastiaan