mdupor

Senior Software Engineer at Asseco SEE

Member Since 1 Year Ago

Rijeka

Experience Points
24,410
Total
Experience

590 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
227
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.

  • Community Pillar

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

Level 5
24,410 XP
Jan
21
2 days ago
Activity icon

Replied to CI/CD Pipelines For Laravel Packages

Oh, migrations needed to be ran. Thanks, working now!

Activity icon

Replied to CI/CD Pipelines For Laravel Packages

Well I did exactly that, however running that returns:

Response status code [500] is not a successful status code. Failed asserting that false is true.

But I'm wondering how would the request even work here? Does Orchestral T. provide some sort of workaround behind the fact that server is not up and running? How can it get to the route?

Jan
19
4 days ago
Activity icon

Replied to CI/CD Pipelines For Laravel Packages

I'm not quite sure how to do that. Testbench documentation is outdated (at least the one I could find here).

Do you have any resources where I could look at to get me started?

Activity icon

Replied to CI/CD Pipelines For Laravel Packages

Wouldn't this be just a workaround? Some things are simple CRUD stuff, but other have minor logic which didn't make sense for me to pull out of controllers. Yes, package is public https://github.com/asseco-voice/laravel-custom-fields

Activity icon

Started a new Conversation CI/CD Pipelines For Laravel Packages

How would I proceed in building a CI/CD pipeline for a package? Specifically what is confusing is how am I supposed to enrich it with Laravel specific things.

I can set up the pipeline to run the tests which will work out of the box, however my package has API routes as well and I would like to test them out as well. The issue I have is that I can't start a package by itself with something like artisan serve or bringing it up as a stand-alone solution.

It came to mind to set up a pipeline to create a new Laravel project which would require the package, bring up the server and test the routes, but is that really the way to go?

Dec
12
1 month ago
Activity icon

Started a new Conversation Laravel Logging Permissions

How are log permissions supposed to work? https://laravel.com/docs/8.x/logging#configuring-the-single-and-daily-channels

        'daily' => [
            'driver'     => 'daily',
            'tap'        => [CustomizeFormatter::class],
            'path'       => storage_path('logs/laravel.log'),
            'level'      => 'debug',
            'days'       => 14,
            'permission' => 664,
        ],

I tried with numeric value as well as doing a string like '0664', and logs get created with --w--wx--T permissions? What am I missing here?

Also, how do I control the owner of the log file? Usually it is daemon:daemon, but last day it got created as a root:root and it broke everything.

Nov
20
2 months ago
Activity icon

Awarded Best Reply on Mailable Storage Attachment

Found it, Laravel has attachFromStorage() method which does the job.

Activity icon

Replied to Mailable Storage Attachment

Found it, Laravel has attachFromStorage() method which does the job.

Activity icon

Started a new Conversation Mailable Storage Attachment

How are you supposed to attach something from storage to email? I am storing it as $request->file('attachment')->store('attachments'); and then within the mailable:

foreach ($attachments as $attachment) {
    $this->attach($attachment->path, [
        'as'   => $attachment->name,
        'mime' => $attachment->mime_type
    ]);
}

It is telling me that Unable to open file for reading. And if I instead of path include a Storage::get($attachment->path) it fails complaining about UTF-8. What is the right way to do it?

Nov
18
2 months ago
Activity icon

Replied to Overriding Core Classes

It feels a bit hacky to me. I ended up using the macros for the job because a lot of classes down the road just aren't containerized and I didn't want to meddle up more than needed. Thinking about future upgrades also here. Thanks anyway!

Nov
17
2 months ago
Activity icon

Replied to Overriding Core Classes

@martinbean is it possible to provide a natural follow-definition for a defined macro without digging into how IDE itself resolves it? Only thing why I'm reluctant to use macro is because from migration perspective it looks as non-existing method

Activity icon

Replied to Overriding Core Classes

Also usually yes :) In this case I have microservices interconnected, and IAM is a single service holding all users. In this setup, created_by references user ID extracted from incoming token

Activity icon

Replied to Overriding Core Classes

@tippin usually yes, but as I said to @martinbean Builder class isn't being pulled from container, but rather instantiated in a standard PHP way. So if I bind it to the container it will do nothing since Laravel codebase isn't calling a bound class.

@martinbean one minor detail passed by you, I am not converting the original timestamps, but adding a created_BY and updated_BY to have indication about the user who performed creation/editing. Macro is always an option as @tippin also suggested.

Maybe all things aside, it would be better to have those explicit rather than implicit, so macros may be a good way to go...

Activity icon

Replied to Overriding Core Classes

I really don't want to replace originally injected Blueprint in all migrations. Especially given the fact that this spans across ~10 services, and later onboarding new team members, it will wreak havoc with new migrations etc.

Activity icon

Replied to Overriding Core Classes

@martinbean I tried implementing this in a service provider boot() method, however it doesn't work (tried register() also). Unless I've done something wrong, I presume it doesn't work because Blueprint isn't actually bound in the container. Schema is though. So I've tried

$this->app->extend(Schema::class, function ($service, $app) {
    return new SchemaDecorator($service);
});

And then within the decorator doing:

use ForwardsCalls;

protected $schema;

public function __construct(Schema $schema)
{
    $this->schema = $schema;
}

public function __call($method, $parameters)
{
    return $this->forwardCallTo($this->schema, $method, $parameters);
}

protected function createBlueprint($table, Closure $callback = null)
{
    $prefix = $this->schema->connection->getConfig('prefix_indexes')
        ? $this->schema->connection->getConfig('prefix')
        : '';

    if (isset($this->schema->resolver)) {
        return call_user_func($this->schema->resolver, $table, $callback, $prefix);
    }

    return new BlueprintExtension($table, $callback, $prefix);
}

Having the extension look like:

class BlueprintExtension extends Blueprint
{
    public function timestamps($precision = 0)
    {
        parent::timestamps($precision);

        $this->string('created_by')->nullable();

        $this->string('updated_by')->nullable();
    }
}

But this didn't work also. I tried throwing some dd()'s around the new classes and they never get triggered.

@tippin macros work for non-existing methods, using it like this doesn't override or change the original functionality at all.

Activity icon

Started a new Conversation Overriding Core Classes

I'm failing to understand as to how would one extend Laravel core classes. There is this: https://laravel.com/docs/8.x/container#extending-bindings but how would the decorated service look like, and why does it accept original service? What should the decorated service return? How would I override a method from original service?

For example I would like to override Blueprint class timestamps() method. So I'd have:

$this->app->extend(Blueprint::class, function ($service, $app) {

    return new BlueprintExtended($service);
});

And I'm stuck from there. I have no idea how should the class look like.

I tried with:

    private Blueprint $blueprint;

    public function __construct(Blueprint $blueprint)
    {
        $this->blueprint = $blueprint;
    }

    public function timestamps($precision = 0)
    {
        $this->blueprint->timestamps($precision);

        $this->blueprint->string('created_by')->nullable();

        $this->blueprint->string('updated_by')->nullable();
    }

But this does nothing...

Aug
07
5 months ago
Activity icon

Replied to Running In Console Micro Optimizations

Well yeah, exactly...but I've noticed by using Clockwork profiler that a portion of a response is framework booting. Since PHP is the way it is, booting happens on every request over again, so I assume it would cut some time off if I used micro-optimizations :)

Aug
06
5 months ago
Activity icon

Started a new Conversation Running In Console Micro Optimizations

I was wondering if I can use app()->runningInConsole() for my Service Provider micro optimizations?

For example:

public function boot()
{
    $this->publishes([__DIR__ . '/Config/containers.php' => config_path('containers.php'),]);

    $this->registerCreator();
    $this->registerMigrateMakeCommand();

    $this->commands([
        'my.command.migrate.make',
    ]);
}

The whole purpose of the things within the boot() method is to publish the configuration, and provide additional methods when using the migrations.

I can't see a scenario where a request would trigger this part of the code.

Would it be wise then to do:

public function boot()
{
    if(app()->runningInConsole()) {

        $this->publishes([__DIR__ . '/Config/containers.php' => config_path('containers.php'),]);

        $this->registerCreator();
        $this->registerMigrateMakeCommand();

        $this->commands([
            'my.command.migrate.make',
        ]);
    }
}

So that if a standard request is made to prevent running these things unnecessarily?