spacedog4

spacedog4

Member Since 2 Years Ago

Umuarama - PR, Brazil

Experience Points
78,520
Total
Experience

1,480 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
720
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 16
78,520 XP
Oct
19
1 day ago
Activity icon

Commented on Use TailwindUI For The Public Pages

I've installed, but didn't got the dump result on screen

Oct
16
4 days ago
Activity icon

Commented on Use TailwindUI For The Public Pages

What extension do you use to show the die and dump result on screen without having to open network on dev tools?

Oct
13
1 week ago
Activity icon

Commented on Meet Teamsy

I do, the logic can be the same, I can get much stuff from this series

Oct
09
1 week ago
Activity icon

Commented on Tenant Global Scope

Great video and great teacher Kevin, I was waiting for this lesson on laracast, feeling excited

Activity icon

Commented on Meet Teamsy

Great serie, how about multi database?

Oct
01
2 weeks ago
Activity icon

Awarded Best Reply on Pusher With Multy-tenancy

UPDATE: This solution worked for notifications, but not for broadcast

Okay, so what I did was create one pusher channel for each tenant, stored each credentials in .env file and added as an app on config/websocket.php.

In my layout file, I already was loading some initial data, as settings, authenticated user and permissions, so I added the pusher key and cluster to it

window.App = {
    super: '{{ !! auth()->user()->super }}',
    permissions: @json(auth()->user()->permissions()),
    settings: @json(App\Setting::getAll()),
    pusher: @json(\TenantManager::getPusher())  // <--- here
}

In TenantManager I get the pusher key and cluster based on the subdomain, I probably need to add more secury in this part, but for development I think is good

    public function getPusher()
    {
        $tenant = TenantManager::identifyTenant(request()->getHttpHost());

        $websocketApp = Arr::first(config('websockets.apps'), function ($app) use ($tenant) {
            return $app['name'] == $tenant;
        });

        return [
            'key'     => $websocketApp['key'],
            'cluster' => $websocketApp['cluster']
        ];
    }

And final, on bootstrap.js I register Laravel Echo based on the pusher key and cluster for the tenant

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: window.App.pusher.key,
    cluster: window.App.pusher.cluster,
    encrypted: true,
    disableStats: true,
});

Do you think there is something that could ruined my project or a big window of unsecurity?

Sep
29
3 weeks ago
Activity icon

Replied to Pusher With Multy-tenancy

UPDATE: This solution worked for notifications, but not for broadcast

Okay, so what I did was create one pusher channel for each tenant, stored each credentials in .env file and added as an app on config/websocket.php.

In my layout file, I already was loading some initial data, as settings, authenticated user and permissions, so I added the pusher key and cluster to it

window.App = {
    super: '{{ !! auth()->user()->super }}',
    permissions: @json(auth()->user()->permissions()),
    settings: @json(App\Setting::getAll()),
    pusher: @json(\TenantManager::getPusher())  // <--- here
}

In TenantManager I get the pusher key and cluster based on the subdomain, I probably need to add more secury in this part, but for development I think is good

    public function getPusher()
    {
        $tenant = TenantManager::identifyTenant(request()->getHttpHost());

        $websocketApp = Arr::first(config('websockets.apps'), function ($app) use ($tenant) {
            return $app['name'] == $tenant;
        });

        return [
            'key'     => $websocketApp['key'],
            'cluster' => $websocketApp['cluster']
        ];
    }

And final, on bootstrap.js I register Laravel Echo based on the pusher key and cluster for the tenant

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: window.App.pusher.key,
    cluster: window.App.pusher.cluster,
    encrypted: true,
    disableStats: true,
});

Do you think there is something that could ruined my project or a big window of unsecurity?

Activity icon

Started a new Conversation Pusher With Multy-tenancy

When working with broadcast, pusher and mult-tenant should I have a project on pusher for each tenant, or have just one for all the tenants and control with the channels on laravel?

My fears are that one tenant could listen to the other, private channels area not a problem, but public channels could be listened

Activity icon

Replied to Insert Multiple Records In One Query

Is there a reason for my code insert just the first item on the array?

MovementStep::insert(
            [
                'name' => 'Em espera',
                'color' => '#999999',
                'order' => 0,
                'default' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Em andamento',
                'color' => '#FCC400',
                'order' => 1,
                'default' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Concluido',
                'color' => '#68BC00',
                'order' => 2,
                'default' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ]
        );
Activity icon

Started a new Conversation Identify Tenant By Subdomain On Policy Class

Today I'm identifing the tenant by the subdomain on a Middleware just with this

public function handle(Request $request, Closure $next)
{
    $tenant = TenantManager::getTenant($request->getHttpHost());
    TenantManager::setDatabaseConnection($tenant);
    return $next($request);
}

But I have a Policy that register all permissions and define it on the AuthServiceProvider, in the boot method, so it tryies to register the permissions before passing thought the middleware.

The permissions table is in the tenant database, so I have to identify it before registering

Should I identify the tenant inside the policy or there is a better way to do that?

I'm identifying the tenant again in the policy with this code

$tenant = TenantManager::getTenant(request()->getHttpHost());
TenantManager::setDatabaseConnection($tenant);
Sep
26
3 weeks ago
Activity icon

Replied to Use And Storage Of Database Credentials Within A Multi Tenancy App.

This is exacly what I was looking for, I already have a multi tenancy system where I store each tenant in the .env like this

DB_CUSTOMER_1_HOST=
DB_CUSTOMER_1_USERNAME=
DB_CUSTOMER_1_PASSWORD=
...

DB_CUSTOMER_2_HOST=
DB_CUSTOMER_2_USERNAME=
DB_CUSTOMER_2_PASSWORD=
...

and have to create one database connection for each customer as well, this is a lot when I need to create a new tenant have to specify it on system database, .env, database file three times, one for local, another for development and another for production, I find myself forgetting some peace every time

Sep
25
3 weeks ago
Activity icon

Commented on The Password Reset Flow

How did you went from the contract to the actual class on 6:29?

Sep
24
3 weeks ago
Activity icon

Started a new Conversation Add Subtitles On Laracast Lessons

Hey guys, I'm from Brazil and can watch laracast videos without a problem. I don't know how many of you, live on a country that English is not a native language, but I'd love to have subtitles on laracast videos.

It can begin with just english subtitles, and maybe add an option to the community add or correct subtitles.

A guy that works with me is looking on the entire internet for good and updated lessons of laravel, and he can't find, he would like to watch the lessons of laracast, but he doesn't understand english, I know that it is almost a requirement to a developer to know at least a bit of english, but in my country it is not that easy to learn english (second language on school is spanish and the courses are expensive).

How can we request Jeffrey to add this in laracast, and just to know, who else think that this is a good thing to be added?

Write down here you country or if you see your country in the comments, just like it.

Sep
23
3 weeks ago
Activity icon

Started a new Conversation Prevent Broadcast Notification To Be Added To The Queue

I'm using queue to generate some document, after generating it, I send a notification to the user, telling that his documents has been generated, but after sending the notification, laravel add the broadcast to the end of the queue, so at the end of the day, the user will be notified just when all files has been generated

How can I prevent my notification to be added to the queue?

This is my notification class:

<?php

namespace App\Notifications;

use App\Report;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;

class MovementReportStatusChanged extends Notification {

    /**
     * @var Report
     */
    private $report;

    /**
     * Create a new notification instance.
     *
     * @param Report $report
     */
    public function __construct(Report $report)
    {
        //
        $this->report = $report;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        if ($notifiable->settings->disabled_notifications && in_array(class_basename($this), $notifiable->settings->disabled_notifications)) {
            return [];
        }

        return ['database', 'broadcast'];
    }

    public function toArray($notifiable)
    {
        if ($this->report->status == 'finished') {
            return [
                'title' => 'Relatório concluído',
                'body'  => "Seu relatório já está pronto, clique aqui para acessa-lo",
                'link'  => $this->report->file,
                'blank' => true,
                'icon'  => 'movement'
            ];
        } else if ($this->report->status == 'failed') {
            return [
                'title' => 'Relatório falhou',
                'body'  => "Desculpe, algo deu errado ao gerar o relatório, tente novamente",
                'link'  => null,
                'icon'  => 'movement'
            ];
        }

        return [];
    }
}

I tryied adding these lines as I thought it would work after reading this discussion on github, but it didn't

https://github.com/laravel/framework/pull/16867

public function broadcastNow()
    {
        return true;
    }
Sep
16
1 month ago
Activity icon

Commented on How It Works

Can I work with livewire and vue in same project without having trouble?

Sep
14
1 month ago
Activity icon

Replied to Laravel With Error

Try this

use Illuminate\Validation\ValidationException;

throw ValidationException::withMessages(['my-error-name' => 'my-error-content']);
Sep
08
1 month ago
Activity icon

Commented on Squash A Massive Migrations Folder

That can speed up my phpunit tests? it tooks minutes just to run the migrations

Sep
04
1 month ago
Activity icon

Commented on Search Dropdown UX With Alpine.js

Is there this helpers like away and keypress on window also in vue?

Sep
02
1 month ago
Activity icon

Commented on Roman Numerals Kata

Doing some research, it apears that you need to add an overline to above the letter to represent numbers bigger than 3999, the overline represents the number times 1000

V = 5
_
V = 5000
 _
MV = 4000

But I don't know how to represent this overline in text.

Doing more research, people are representing them by wraping in parentheses, (V) = 5000

anyway, just sharing some research

Aug
19
2 months ago
Activity icon

Commented on TodoMVC With Alpine: Part 1

Backend should't receive critical data from the front, as an example, if you add a product to the shopping cart, and send to the backend the value of the product, you can't use that value, you have to get the id of the product and get the value directly from the database.

Aug
06
2 months ago
Activity icon

Commented on Recaptcha Component

I'm afraid to use alpine and at some point, realize that I reachead a limit and need to convert all my alpine code to vuejs

Aug
03
2 months ago
Activity icon

Commented on Change Detection

Oh, and I was doing

let a = this.a
a.foo = 'bar'

this.a = a

lol

Jul
30
2 months ago
Activity icon

Replied to Insert Records From Different Tables With One Query

I also realized that if I used insert I would need to make another query to get the instance

Jul
29
2 months ago
Activity icon

Replied to Insert Records From Different Tables With One Query

I mean,

" Insert ...; insert ...; insert ...; "

would be better than calling the builder 3 times

Activity icon

Started a new Conversation Insert Records From Different Tables With One Query

I want to use the bennefit of factories, I'm improving the performance of my tests, today I have more the 400 tests, I need to refresh the database before each test, but also need 3 records from 3 different tables on each test (not all, but most)

I want to transform this code

$this->empresa = factory(Empresa::class)->create([
    'codigoempresa' => 1
]);
$pessoa = factory(Pessoas::class)->create([
    'codigoempresa' => 1,
    'codigopes' => 1
]);

$this->apiUser = factory(ApiUser::class)->create([
    'codigoempresa' => $this->empresa->codigoempresa,
    'codigopes'     => $pessoa->codigopes,
    'api_token'     => $this->token
]);

in just one query for performance improvement, I was thinking in DB::raw() but I don't know how to integrate that with factories

Activity icon

Replied to Testing Landlord And Tenant Databases.

@phpmick You can create a helper class and call that function I mentioned above directly from your test, after that you can call User::first() that it will point to the correct connection

Activity icon

Replied to Testing Landlord And Tenant Databases.

I work with tenant, I have all my databases settet on .env and this function that helps me to change the connection easly

    public static function setConnection($env_connection)
    {
        $env_connection = strtoupper($env_connection);

        config(['database.connections.mysql' => [
            'driver'   => 'mysql',
            'host'     => env("DB_{$env_connection}_HOST"),
            'database' => env("DB_{$env_connection}_DATABASE"),
            'username' => env("DB_{$env_connection}_USERNAME"),
            'password' => env("DB_{$env_connection}_PASSWORD"),
            'strict' => false,
        ]]);

        \DB::reconnect('mysql');
    }
May
16
5 months ago
Activity icon

Commented on Everything You Need To Know About Dotfiles

alias docker-composer="docker-compose" I make that mistake all the time lol