Punksolid

Punksolid

Member Since 2 Years Ago

Culiacán

Experience Points 52,880
Experience Level 11

2,120 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 447
Lessons
Completed
Best Reply Awards 12
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

12 Jul
4 days ago

Punksolid left a reply on Testing Registration

Hi @wyatt44 Thats because when you do a $this->posts it generates a normal http request without the headers for json.

insetead try


$call = $this->postJson('/register');

Also, an api cannot redirect, apis are stateless

Are you trying to test the frontend too?

22 Jun
3 weeks ago

Punksolid left a reply on Laravel Echo Problem !!

Hi @moktar maybe is the format you are using, are you sure .data exists?

To debug that, share what appears in your browser > network tab, then select the WS filter, and it should show the registries of each message you are sending from your backend.

17 Jun
4 weeks ago

Punksolid left a reply on Queue "Job" Or "Mail" That The Job Sends?

Hi @thebigk why you NewsLetter class says Digest?

07 Jun
1 month ago

Punksolid left a reply on Import An Excel File In Database Driver Queue

Hi @juvpengele you checked that the file really was imported there /home/juvenal/Lab/Pro/support-stat/storage/imports/ and with that name?

04 Jun
1 month ago

Punksolid left a reply on CORS Issue

hi @afoysal Could you expand/show the response headers?

Punksolid left a reply on Add Traits To Class With Code

@sa Even the name of that package is warning you. LOL

03 Jun
1 month ago

Punksolid left a reply on Store Date's In MySQL

Hi @h it should be the dateTime method instead of timestamps

$table->dateTime("scheduled_arrival")->nullable();

the table->timestamps() do not have any parameters and are for the created_at and updated_at columns

29 May
1 month ago

Punksolid left a reply on Guide For FrontEnd Multitenant Application?

Hi @gadeoli

I'm in a late stage of a project with the same approach. You have at least two main options to access to your backend. As hyn/tenant separates tenants by host-name by default, you could do a frontend that bypass the main url to your back-end. So if anyone tries to access to hello.world.com you will point it to your backend called hello.api.com with that you will be able to access instantly to the right tenant.

The other approach is the one that I'm doing, you could call a centralized api, and check for the tenant trought user input, for example if a user can have multiple tenants, could have a list of his tenants after login and then set the host-name, or tenant identifier on a header of the request for every future requests.

It depends in what you need, I think that the second approach is good for a mobile app, because you could call an specific api and then let with user input decide which account/tenant will use

28 May
1 month ago

Punksolid left a reply on When Sending Emails, "to" Shows Email Address Of Other Clients

Hi @ldiebold

You could use Notifications for that and send an EmailNotification https://laravel.com/docs/5.8/notifications#mail-notifications

But basically it does a loop internally.

But!, if you want a quick solution I thing you could send a Blind Carbon Copy (bcc) in your mail

Mail::to($recipients)
    ->bcc($evenMoreUsers)
    ->send(new OrderShipped($order));

Punksolid left a reply on Where On Two Relationship Objects Passing Parameters

@MHERY - That's okey. As a note, if you don't want to filter ratings but just want to filter his relationships you could pass inside a with an array and a key with a closure. In that you will not be filtering Ratings but just its relationships

$evaluations_artist = App\Rating::with(['rateable' => function ($query)  use($review_id) {
    $query->where('_id', $review_id);
}, 'evaluator' => function($q_evaluator) use($user_id){
    $q_evaluator->where('_id', $user_id);
}])->get()

Punksolid left a reply on Is This Time Normal For My Tests?

@tray2 how did you formatted that way?

27 May
1 month ago

Punksolid left a reply on Is This Time Normal For My Tests?

Hi @ looks very normal, but time depends on the things that your app is doing, assertions, hardware and if you are doing it in memory or a lot of configurations more. If you wanna have a reference here is mine on a core i5 and call some external apis in them

PHPUnit 7.5.10 by Sebastian Bergmann and contributors.

..........................I....................................  63 / 178 ( 35%)
..S........F........S..I................I.....................E 126 / 178 ( 70%)
E....E......................S.....II............S.I.            178 / 178 (100%)

Time: 2.4 minutes, Memory: 84.50 MB

Punksolid left a reply on Notifications Factory For Users

I think it is better to execute manually the notification in your tests, but if you want to generate a lot of dummy data then the factory will help. To do so

Your NotificationFactory.php

<?php

/* @var $factory \Illuminate\Database\Eloquent\Factory */

use Faker\Generator as Faker;

$factory->define(Illuminate\Notifications\DatabaseNotification::class, function (Faker $faker) {
    return [
                'id' => $faker->uuid
    ];
});

When you are going to generate it


        $notification = factory(DatabaseNotification::class)->create([
            "type" => "Namespace\ClassNameOfNotification",
            "notifiable_type" => "Notifiable\Model",
            "notifiable_id" => random_int(8888, 9999), // id of the notifiable model
            "data" => [
                "any"=> "value"
            ]
        ]);

Obviously you could pass any of the values to your factory but if you want to generate it for a real model you will need to pass it in your create.

Punksolid left a reply on Laravel With Branches

There is a concept called MultiTenancy https://www.gartner.com/it-glossary/multitenancy that it is used in a lot of robust applications to separate domains. If it is a student project maybe you need something simpler. Just attaching accounts to users and showing the related information to those accounts using scopes or global scopes.

Punksolid left a reply on Where On Two Relationship Objects Passing Parameters

Do you want to retrieve the evaluator also?

$evaluations_review = Rating::with(['rateable', 'evaluator'])
    ->whereHas('rateable', function($q) use ($review_id){
            $q->where('_id', $review_id);
        })->get();

But keep in mind that you are filtering Ratings that only have specific rateables, and in those will bring his evaluator

Punksolid left a reply on Slow Booting Times

Hi @mprythero I have seen considerable difference on performance depending on the PHP versions, are you using different PHP versions in your local than in production?

Also whats the TTFB (Time To First Byte) that the browser says? Sometimes a bad webserver configuration gives a slow response because some dns error or something.

Punksolid left a reply on Where On Two Relationship Objects Passing Parameters

Hi @mhery Where do you get the $review_id? To access to an external variable inside the closure you need to specify trough the use statement

$evaluations_review = Rating::with('rateable')
    ->whereHas('rateable', function($q) use ($review_id){
            $q->where('_id', $review_id);
        })->get();
26 May
1 month ago

Punksolid left a reply on Heroku Laravel 403 Forbidden - Tried All Possible Options But Cant Show Page

@ADRIANMCG85 - You need to install the heroku-cli and then set this way the environment variables

 heroku config:set HELLO=WORLD

To check it just run heroku config and you should see the keys values you just set

Punksolid left a reply on Can I 'shorthand' Setting This Eloquent Relation?

I think that your code is generally acceptable, but do you have many statuses? because if not you could simple have an Enum or Integer representing each status so you don't do two queries to update. If the statuses are going to be dynamic then is it right.

I left you another way to do it but it's basically the same

    Order::find(1)->update([ 'status_id' => Status::whereSlug('order-received')->first()->id ]);
19 May
1 month ago

Punksolid left a reply on Multiple Domains In One Project With Single DB

@SLON - You could do it with middlewares also. For example a SetDomainConfigMiddleware.php

class SetWialonTokenMiddleware
{

    public function handle($request, Closure $next)
    {
    $configurations = Config::whereDomain(request('domain'))->first(), //you retrieve from whatever place you have the configurations, if you need from a system database, then just set it
    
        config([
        'database.default' => $configurations->database
    ]);

        return $next($request);
    }

}

I do something similar but the opposite, same domain multiple tenants with separate database. The middlewares work good

18 May
1 month ago

Punksolid left a reply on Multiple Domains In One Project With Single DB

looks like you will need to set the settings for each queue and mail before make it work.

What about using events to set the global config valiables on the fly?

16 May
2 months ago

Punksolid left a reply on Laravel Forge Horizon Exited Too Quickly (process Log May Have Details)

It was not the same issue but very similar and your answer helped me.

I had an extra space in the path provided. Y deleted it but I left the /home/forge/default and then just left the optional in blank. And had the same error.

But when I putted the path of my website project it worked. So I assume that when you left in blank it uses the default. And as recommended I deleted it before.

So if anyone has the same problem, make sure you specify a path directory that exists.

Punksolid left a reply on Got Two Tables, User Replicates Some Row From First Table To Second, How To Improve Loading Times?

Hi @thgz Do you use some kind of javascript? How is your controller?

You could combine pagination with infinite asynchronous scroll.

Punksolid left a reply on How To Add Calculated Fields To An Eloquent Resource?

Hi @chadhutchins I would go putting that logic in UserModel, and use it in the UserResource.

There is a non strict approach called Fat Models Thin Controllers that I recommend, you could use that method in other non controller classes.

Punksolid left a reply on Static Route "/api/v1/admin/vendors/categories" Is Shadowed By Previously Defined Variable Route "/api/v1/admin/vendors/([^/]+)" For Method "GET"

Hi @faisal just put your "/api/v1/admin/vendors/categories" before "/api/v1/admin/vendors/([^/]+)"

The //vendor category section before the //vendor section

Punksolid left a reply on Prevent Site Going Down When Route Does Not Exist

Hi @chilitomato When you put Laravel in production, SHOULD have set the environmental variable DEBUG set to false. With that, all exceptions are going to be catch in the internal log, and the views are going to show a view with the proper error code. Normally a 404 or a 500 internal server error.

If you want to personalize the behavior for example when a 404 occurs In the handler.php file you could catch any exception and make another behavior, maybe a redirect or something

    public function render($request, Exception $exception)
    {
        if ($exception instanceof \HttpException){ // You could set the specific exception that you wanna specify
            return view("errors.404"); // make a redirect or change to a specific view
        }
        return parent::render($request, $exception);
    }

Punksolid left a reply on Laravel Query Builder - How To Select Pairs Of Items?

Hi @grigelionis I think I didn't understand what do you mean with pairs of domains. If you want to retrieve the 2 most clicked domains is something like this

Link::orderBy('clicks', 'DESC')->take(2)->get();

Is that what you want? Or do you want all registries in some kind of order?

14 May
2 months ago

Punksolid left a reply on Laravel Echo Not Receiving Broadcasted Notifications Via Laravel Websockets.

I don't see any issue with your code. I have this working right now, I have changed the notifiable for an account model. But I see almost the same as yours

     window.Echo.private('App.Account.' + this.$store.getters.account_id)
        .notification((notification) => {
          console.log('NOTIFICATION hit')
          this.notifications.push({
            id: notification.id,
            message: notification.message,
            link: notification.link
          })

Punksolid left a reply on Laravel Echo Not Receiving Broadcasted Notifications Via Laravel Websockets.

Hi @cyberkingyash Your clients connects to pusher? You will see in the pusher debug a connected row info.

13 May
2 months ago

Punksolid left a reply on Best Autocomplete For Laravel Projects With MySQL Backend

I think it's not specifically the answer you are looking for, but I think that what are you trying to achieve is a lot simpler with vuejs.

this vuejs component does something similar of what you want and is easy to use. I use it in one of my projects.

https://element.eleme.io/#/remote-search

Hope it helps

Punksolid left a reply on Private Channel Is Not Consoling The Output. However, Public Channel / Channel('channel_name') Is Working Fine.

@SANTA123 - There are two parts of that data flow, one from the server to pusher and another one from your client to pusher.

In pusher there is a debug tab. Could you see the client connection there? If you send a broadcast message from you server to pusher does it appears there?

12 May
2 months ago

Punksolid left a reply on Private Channel Is Not Consoling The Output. However, Public Channel / Channel('channel_name') Is Working Fine.

Hi @santa123 Private channels need to do an authentication first. Check if it is doing a XHR request to the default route of auth broadcasting http://127.0.0.1:8000/broadcasting/auth

and then check in the route channels.php if you have authorization defined for that channel


Broadcast::channel('App.User.{id}', function ($user, $id) {
//    Logic to permit access to that chat
    return (int) $user->id === (int) $id;
});

11 May
2 months ago

Punksolid left a reply on Telescope Links Don't Work

Hi @jenya There are endpoints to view telescope resources, however you are trying to visit

telescope/models and that one is a POST endpoint.

There is no GET endpoint for telescope/models

Punksolid left a reply on DB And Eloquent Structure For User Preferences

Hi @r3tn3 I think that if the settings aren't many you could save the defaults into the personalized fields that haven't been set, so you will retrieve them only from one place.

09 May
2 months ago

Punksolid started a new conversation Laravel Telescope In Production

Hi

I been using Laravel Telescope in local and staging server and is incredibly useful, but now that I have my production server, I found that I am already dependent on telescope. So I would like to use it on production but I'm concerned about the performance impact, because it does a lot of things. However I think I only need to activate the exceptions module and maybe one or two more.

Do you recommend it? or do you tweak something to dont impact too much on performance?

Thanks

Punksolid left a reply on Im Very New Testing With Laravel

Hi @ Should be integer.

        $response->assertStatus(200);

As a tip I recommend you to use $response->assertSuccessful(); it comprehends more successful codes

Punksolid left a reply on Display 4 Or More Different Tables In One View Page

public function showAll() {
    $posts = PostModel::all();
    $comments = CommentModel::all();
    $users = UserModel::all();
    $accounts = AccountModel::all();

    return view('views.all')->with(compact('posts','comments','users','accounts'));
}

You do all in one controller. However you should paginate them.

08 May
2 months ago

Punksolid left a reply on Two Tables From One Controller

hi @

Laravel will manage "automagically" the fields created_at and ```updated_at```` even if you are not calling them.

You have two options, say explicitly that you are not going to use them.

protected $timestams = false; or add those columns to your table so you need to

            $table->timestamps();
07 May
2 months ago

Punksolid left a reply on How To Make Where() On Json Filed

Hi @haizone You are trying to make two filters, one around os and another one around the GB.

Laravel provides a simple simple jsonwhere clause within the normal where.

You should be able to do this.

        $product_query = Product::query();
        if($request->filled('os')){
            $product_query->where("specfields->os->value", $request->os);
        }
        if($request->filled('memory')) {
            //here maybe you will need to parse your request because of the slashes
            $product_query->where("specfields->memory->value", $request->memory);
        }
        $products = $product_query->whereHas("category", function($category_query) use ($category){
            return $category_query->where('id', $category->id);
        })->get();   

        return $products;

Punksolid left a reply on Pusher With Laravel 5.6 Not Working

There are two steps to make it work, one from your server to pusher, and another one from pusher to your client. First make sure one of them is working. In the debug tab in in the pusher panel you could see the messages and the connections, and simulate them, you will see the messages received by your server and the connections from your client.

Put in your client the listener for the channel you are trying to do.

windows.Echo.channel('orders')
    .listen('OrderShipped', (e) => {
        console.log(e.order.name);
    });
06 May
2 months ago

Punksolid left a reply on Seed BelongsTo And HasMany Relations Together

Honestly you caught me unarmed, I haven't taken care so much about the time responses on my projects, I only try to implement good practices.

It looks that that time isn't bad. 'Average Page Loads 2018'

Also you are sending the complete view in your response, so it looks fair. It looks that you are doing the query right. So maybe you could do some steps further to get lower response times.

1 Cache the eloquent call and flush it in the process of storing. 2 Cache the entire HTTP response with (https://github.com/spatie/laravel-responsecache)

I only tried the first one with good results.

Maybe you could also translate the eloquent query to a DB query.

Let me know if you could lower the response time.

Note: I almost forget, are you using PHP 7.3?

Punksolid left a reply on Pusher With Laravel 5.6 Not Working

Hi @mohmmaedfayez make sure you set this in your .env file

BROADCAST_DRIVER=pusher

05 May
2 months ago

Punksolid left a reply on Passing Data From One Vue To Another (redirect And Display)

@DEEPU07 - so maybe this block is not working

     if(response.status === 200) {
           this.$router.push({ path : '/city' });
        }

So the request is properly done, but the code inside the if is executing?

I had a similar issue, and it happened to be outside my component, in the route beforeEach block where I had the permission logic. Do you have some type of filtering like that in routes?

Punksolid left a reply on Passing Data From One Vue To Another (redirect And Display)

Hi @deepu07 The response you have is it a 200 code?, the code after that conditional is executing?

Punksolid left a reply on REST API Update Architecture Using Specific Actions

@kovbo I had/have the same doubt as you, as I researched there are things that aren't perfect in REST, one of the better explanations that helped me was this Adam Wathan spech. It isnt exactly about resful but I think it could help you too

https://www.youtube.com/watch?v=MF0jFKvS4SI

Punksolid left a reply on Changing DB_PASSWORD

@moukbel I think that if the server is already running, executing Artisan on a route, will not reflect changes until you stop the server in which is running.

Punksolid left a reply on Seed BelongsTo And HasMany Relations Together

@JENYA - First of all, how are you calling the info that you are displaying? Shouldn't take too much nor should show the info wrong with pagination. I recommend you to use pagination. So explain what is it wrong to help you.

However you could do this things to optimize the response:

1.- But to optimize your query you should eager load the info. 2.- Set foreign keys in database. 3.- Specify in the get() the fields you want to retrieve.

04 May
2 months ago

Punksolid left a reply on Changing DB_PASSWORD

If you are using php artisan serve to develop your app you should restart the server.

Sometimes the config is cached so you could do a php artisan config:cache

Punksolid left a reply on Where To Store/how To Retrieve Client Id Of Logged In User?

It depends, if client_id if not going to change, if you save it in a session it will be faster to access to the related data.

If client_id is going to be updated by other users or frequently maybe you should access it from auth()->user->client->id or however your relationship is