michapietsch

michapietsch

Member Since 3 Months Ago

Greifswald

Experience Points 14,740
Experience
Level
Lessons Completed 130
Lessons
Completed
Best Reply Awards 2
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.

03 Dec
1 month ago

michapietsch left a reply on Laravel Pluck An Array From Nested Relationship

You're right, @divpro, now this needs to be put into context.

You want to access the path tags inside a closure which retrieves the related tasks. I'm not sure how you can access it there.

But you're actually looking for only one specific path, right? Maybe there's a better way, but why not use an array with the path tags and then start your query for the tasks and pass that variable to the closure?

02 Dec
1 month ago

michapietsch left a reply on Laravel Pluck An Array From Nested Relationship

Hi @divpro, thanks for the clarification. Now I understand the core of your question.

You get a collection, when you retrieve the tags for a path a pluck the 'name' column. You can now transform the collection into an array with the toArray() method.

For example you can get the tags for a path as an array:

$path->tags()->pluck('name')->toArray();

// Or as I see you called the relationship method pathtags() instead of tags():
$path->pathtags()->pluck('name')->toArray();
30 Nov
1 month ago

michapietsch left a reply on CSS Modules In Blade

@thaden Ah, interesting, thanks for the clarification! So many ways to do things these days! :) I haven't had the pleasure with PostCSS, yet.

michapietsch left a reply on Laravel Pluck An Array From Nested Relationship

@divpro Ah ok, so XML, PHP and CSS3 are the tags of the path and if a task has one, two or all three of them, then it's a match, but if a task has any other tag, which is not in these path tags, then this means this tasks is reaching beyond the path scope and that task should not be included?

michapietsch left a reply on Passing Value To Edit Form, Update() Returns Null Instead, Why?

Hi, are the sales displayed correctly when you load the form? Does the answer from the server with all the sales have the correct format, that means an array with sales and each sale has a itemID property?

michapietsch left a reply on CSS Modules In Blade

Hi, can you please give more information on your current workflow outside of Laravel blade files? Are you using CSS-in-JS with e.g. React or Vue?

michapietsch left a reply on Laravel Pluck An Array From Nested Relationship

Hi, please confirm that I get the basic idea right: Paths have tags, tasks have tags. Both are many-to-many relationships. Basically you want to retrieve a collection of paths, each with a collection of its tags, and each tag with a collection of its tasks. But now you want to filter that down and exclude certain tags, so that tasks with these tags are excluded, and from the paths you want to exclude tags associated with any of these excluded tasks?

24 Nov
1 month ago

michapietsch left a reply on Package:autodiscover

Did you upgrade? I think the postAutoloadDump is an old command. I believe I ran in the same error... If you upgraded, please compare your composer.json to the one you find at Github for the version you are now running.

23 Nov
1 month ago

michapietsch left a reply on Write Each Part Html

I don't completely understand the part where you add the myname HTML.

But I think you could first simplify your code and not use the switch because inside it always uses the module name. So instead of switch and also instead of name!=footer etc. you could check if the module name exists in an array of allowed modules and then just generate the view include. You are already looping through all of them.

michapietsch left a reply on Submitting An Ajax Get Request Returns Undefined

Could you try and use response as an argument for the success fallback? Maybe data clashes with the existing var.

michapietsch left a reply on Package:autodiscover

Could you please be more specific? Do you get error messages?

michapietsch left a reply on ({response})

Seems the response is not an object and by adding the curly braces you create an object from an array.

Please check the response in DevTools to see what you get from the server.

michapietsch left a reply on 405 Method Not Allowed Laravel Ajax

Where do you pass the ID in the Ajax request? I can only see you add the CSRF token.

06 Nov
2 months ago

michapietsch left a reply on PHP Fatal Error: Uncaught Error: Class 'Monolog\Handler\StreamHandler' Not Found

So according to your composer.lock you have version 1.12 installed. I just checked the Github repo for Monolog, chose the 1.12 tag and there the Class exists: https://github.com/Seldaek/monolog/blob/1.12.0/src/Monolog/Handler/StreamHandler.php

Can you confirm, that in the vendor directory, amongst the monolog files you can see this class?

To doubt the mere existence of this class file might seem weird, but who knows what weird things could happen? :)

michapietsch left a reply on Validation Radio-Button

I got curious, because I'm from Germany. :)

Can you show us more code? The above snippet does not handle the inline styles, of course .

michapietsch started a new conversation Delete From Pivot Table Only One Of Multiple Associations

Hi,

I wasn't able to find an existing thread. Please point me to it if you know of one!

Imagine you have multiple associations in a many-to-many relationship. Like when for some reason there are multiple identic products in a cart.

Why aren't they merged to one entry? Well, maybe some will get a gift box, the others won't.

Whatever the reason, there are multiple entries and we COULD to remove a specific one with newPivotStatement... -- BUT we'd need to know exactly what distinguishes this entry to formulate the where clauses. Maybe it's the gift box, maybe something else. Don't know, shouldn't need to care.

I came across the suggestion to include the id in withPivot and use an extra model to delete the entry.

What do think about this? What alternatives are there to consider?

Micha

20 Oct
3 months ago

michapietsch left a reply on A General (long) Question On TDD And Test Organization

Came here looking for advice on test organization. It can be tough in complex applications! You're right, on unit level it's quite straightforward but if you're testing integration or E2E then the number of combinations can be overwhelming!

Let's pick out validation as an example:

First, I think testing on unit level can ensure that request does not get processed further if it's not valid. But I'd go as far as to test on browser level. Because user experience matters. E.g. does the user get appropriate feedback? I'm a huge fan of browser testing and I'm glad there are great tools to make it easy. It's just my preferred way.

I'd write a test for every aspect you need to cover in development. Even if you're at first just writing down the test definitions it's good documentation for stakeholders. :) Because a lot of work happens in the shadows. The customer will mostly only test the usual path without all the side roads you need to consider and cover and of course you test all of them manually during development. So writing more tests and covering all potential edge cases is a great way of forcing yourself to think about and cover all of them and to make the development process comprehensible to others.

Every single validation rule is a piece of work that needs to be done, tested and continue to work correctly in the future.

michapietsch left a reply on Validation Radio-Button

Hi,

is it just not displayed or could you verify that the error message exists in $errors?

PS: I see you're working on a project in German language. Where you from?

michapietsch left a reply on How To Set Mannual Url (href) In Pagination

Do you use Ajax to get the data and then insert it into the page and now you also want to update the URL in the address bar?

michapietsch left a reply on PHP Fatal Error: Uncaught Error: Class 'Monolog\Handler\StreamHandler' Not Found

composer dump-autoload will make the existing classes available. But does the Class 'Monolog\Handler\StreamHandler' exist? You could check that in the vendor directory.

Now what is the effect of the minimum-stability property? It affects dependency resolution, that means how composer determines which package versions to install. I guess in this case it's about a difference between versions of the Monolog package. The class is expected in it but the installed version somehow does not include it.

That's my guess where I'd look for the cause of the error.

If you want to try to set minimum-stability and your composer.json does not have it, you could add it.

If it doesn't help, could you please look into composer.lock and see which version of Monolog is installed?

19 Oct
3 months ago

michapietsch left a reply on Joins: Cant Understand My Error

Oh, and $this->forms() should be the relationship you set up. So in your case it should be $this->form().

michapietsch left a reply on Joins: Cant Understand My Error

You dumped dump($this->user .... Maybe that is why you only see one user. Try App\Models\User::limit(10) to get ten users. Ok?

If dynamic append does not work you can add it to your model like this:

class User extends Model
{
    protected $appends = ['form_id', 'role_id'];

// more code ...

Now the model wants to append the attributes, but what value should the have? That's what's defined in the methods like for example:


protected function getFormIdAttribute()
{
    return $this->forms()->first();
}

In this method you are free to define which form (in this example) to retrieve. Here you can add an "order by" instruction.

michapietsch left a reply on How To Perform Calculation On A Dynamic Table By Using Javascript

Are you familiar with a debugger? For example Firefox or Chrome developer are great to go through your code step by step while it's executed. I recommend you take a look! It will definitely pay to learn how to use it. There's no way around JS these days and in the beginning I also often wondered why code didn't work until I learned to use these tools to my benefit! :)

michapietsch left a reply on Can I Replace My Code For Where Json Array Contains From Array With Something Better?

@joveice Ah ok, I missed that. So you are looking inside that cast array.

And now you'd like to remove the foreach?

I just learned that whereJsonContains can take an array, just like whereIn.

See https://laravel.com/docs/5.7/queries#json-where-clauses

Could that be what you're looking for?

17 Oct
3 months ago

michapietsch left a reply on Joins: Cant Understand My Error

You don't need ->with('form'). This is what causes the nested arrays.

Make sure you tell Laravel to add the new form_id attribute to the model instance:

  • It can be added in a protected array appends in the model
  • or you use $this->user->append('form_id').

See here: https://laravel.com/docs/5.7/eloquent-serialization#appending-values-to-json (although not limited to JSON)

michapietsch left a reply on Joins: Cant Understand My Error

I recommend you add form_id and role_id to the appends[] array in your user model and use accessors like for example:

protected function getFormIdAttribute()
{
    return $this->forms()->first();
}

michapietsch left a reply on Joins: Cant Understand My Error

You only want the last (latest?) of the user's forms and roles? Then I guess you have to filter the multiple relations in a subquery. Otherwise that's what joins do: They give you all the combinations. That's why one user with three roles produces three rows in the result.

michapietsch left a reply on Can I Replace My Code For Where Json Array Contains From Array With Something Better?

Not tested but shouldn't it be enough to use:

function ($query) use ($request) {
    $query->whereIn('envs', $request->get('env'));
}

michapietsch left a reply on Sharing CSRF Token Between Subdomains

Just to be clear: Both subdomains are served by the same Laravel install?

If that's the case: Did you look into Laravel's CSRF logic? Does it only check the token or indeed check domains/CORS as well?

michapietsch left a reply on How To Perform Calculation On A Dynamic Table By Using Javascript

I don't know if jQuery can handle $('#tb3').each() but whatever the case an ID should only be used once. Maybe you use a class tb3 instead.

That would be the first thing I'd check. I guess tb3 belongs to your trs in tbody? I can't see it in the table markup and suggest you change that to improve your chances for a good answer.

michapietsch left a reply on Access Array Variable For Inserting Into Sql Table.

@Cronix is right: REPLACE get() with first(). I was wrong to suggest to "chain" it.

Also that's the elegant way.

michapietsch left a reply on Access Array Variable For Inserting Into Sql Table.

$assistant['0']really worked? Shouldn't it be [0]? Just now I incidentally noticed it.

michapietsch left a reply on Access Array Variable For Inserting Into Sql Table.

You get a collection of objects. You could chain a ->first() when getting the assistant. Or I think this should work, too: $assistant['0']->NameCounter.