Punksolid

Punksolid

Member Since 2 Years Ago

Culiacán

Experience Points 41,080
Experience Level 9

3,920 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 357
Lessons
Completed
Best Reply Awards 7
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.

19 May
10 hours 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 day 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
3 days 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
5 days 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
6 days 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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 weeks 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 weeks 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

Punksolid left a reply on Seed BelongsTo And HasMany Relations Together

If I understood the your problem right, I think this is the solution

 I want to create 300 Card records and 3 Person records for each Card records, but I still don't understand how to do it

So 300 cards and each card should have 3 persons related


factory(Card::class,300)->create()->each(function($card) {
            factory(Person::class,3)->create([
                "card_id" => $card->id
            ]);
        });

let me know if it works

Punksolid left a reply on Seed BelongsTo And HasMany Relations Together

I think I will understand better your question if you put the migrations. The models looks strange to me. However, whats the ultimate model that are you wanting to create?

Does this helps?

$person = factory(App\Person::class)->create([
    'card_id' => factory(Card::class)->create()->id,
    'doc_id' => factory(Document_Person::class)->create()->id
]);

Punksolid started a new conversation Laravel Homestead Not Working On Manjaro

I think I did everything on the documentation

I installed virtualbox and vagrant as per project configuration. I enter to my project directory executed vendor/bin/homestead make and then vagrant up. Then added the only row 192.168.10.10 homestead.test to my /etc/host file. And then I try to enter to homestead.test and don't work. I tried in Chrome,firefox developer,chromium and firefox. I restarted the machine and nothing.

I think the server is working ok because I don't see anything unusual here

[[email protected] neotrm]$ vagrant reload
==> neotrm: Attempting graceful shutdown of VM...
==> neotrm: Checking if box 'laravel/homestead' version '7.2.1' is up to date...
==> neotrm: Clearing any previously set forwarded ports...
==> neotrm: Clearing any previously set network interfaces...
==> neotrm: Preparing network interfaces based on configuration...
    neotrm: Adapter 1: nat
    neotrm: Adapter 2: hostonly
==> neotrm: Forwarding ports...
    neotrm: 80 (guest) => 8000 (host) (adapter 1)
    neotrm: 443 (guest) => 44300 (host) (adapter 1)
    neotrm: 3306 (guest) => 33060 (host) (adapter 1)
    neotrm: 4040 (guest) => 4040 (host) (adapter 1)
    neotrm: 5432 (guest) => 54320 (host) (adapter 1)
    neotrm: 8025 (guest) => 8025 (host) (adapter 1)
    neotrm: 27017 (guest) => 27017 (host) (adapter 1)
    neotrm: 22 (guest) => 2222 (host) (adapter 1)
==> neotrm: Running 'pre-boot' VM customizations...
==> neotrm: Booting VM...
==> neotrm: Waiting for machine to boot. This may take a few minutes...
    neotrm: SSH address: 127.0.0.1:2222
    neotrm: SSH username: vagrant
    neotrm: SSH auth method: private key
==> neotrm: Machine booted and ready!
==> neotrm: Checking for guest additions in VM...
==> neotrm: Setting hostname...
==> neotrm: Configuring and enabling network interfaces...
==> neotrm: Mounting shared folders...
    neotrm: /vagrant => /home/ze/projects/trm/neotrm
    neotrm: /home/vagrant/code => /home/ze/projects/trm/neotrm
==> neotrm: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> neotrm: flag to force provisioning. Provisioners marked to run always will still run.
[[email protected] neotrm]$ ping homestead.test
PING homestead.test.huawei.net (120.78.181.57) 56(84) bytes of data.
64 bytes from 120.78.181.57 (120.78.181.57): icmp_seq=1 ttl=108 time=214 ms
64 bytes from 120.78.181.57 (120.78.181.57): icmp_seq=2 ttl=108 time=213 ms
64 bytes from 120.78.181.57 (120.78.181.57): icmp_seq=3 ttl=108 time=213 ms
^C
--- homestead.test.huawei.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 316ms
rtt min/avg/max/mdev = 212.836/213.497/214.399/0.760 ms

and also ping is giving data back. But I don't know why doesnt shot the right IP, instead shows homestead.test.huawei.net but I dont know if its the expected behavior.

Any idea on what to check?

Punksolid left a reply on Websockets Private Channel Based On Connection ID?

Hi @jacdev what are you trying to achieve?

Technically you could do a channel called connection and you could connect there using the ID, but I don't think I understood your question.

03 May
2 weeks ago

Punksolid left a reply on Docker

+1 on wanting a docker series.

Many of the Continuous Integration services uses docker to run environment and test the project.

02 May
2 weeks ago

Punksolid left a reply on List States That Has People

Hi @zfdeveloper whereHas is what you need

$posts = App\State::has('cities.users')->get(); //try this 

// But if doesn't work try this one
$posts = App\State::whereHas('cities', function ($query_cities) {
    $query_cities->has('users');
})->get();

Good luck

30 Apr
2 weeks ago

Punksolid left a reply on Laravel Telescope System Requirements

Hi @gversion I use in a testing server with .5 of ram a swap file and telescopes works ok

Punksolid left a reply on How To Give Permission To Access My Android Camera For My Local Ip Address?

You could do some tunneling, there is a simple service that its useful on testing (https://ngrok.com/) after you excecute php artisan serve and install ngrok you could execute ngrok http 8000 and it will give you a public URL that will be internet accesible.

Then you set that URL in the way you tried before.

Punksolid left a reply on How To Extend Or Make Custom PasswordBroker SendResetLink() Method In Laravel 5.8?

@RICHARDEV - Yes, I saw you find the solution while I was responding and seeing my own code.

Glad you solve it

29 Apr
2 weeks ago

Punksolid left a reply on How To Extend Or Make Custom PasswordBroker SendResetLink() Method In Laravel 5.8?

Hi @richardev I did some modifications similar as yours.

So, your project should have a first local entry to that method. In Http/Controllers/Auth you have five classes. Each class has an use statement, where the method that you modified where included, so, in the class that handles the sendResetLink method, that Im not sure but I bet is the ResetPasswordController.php there you could override the sendResetLink method, you could copy paste it there and discard the changes you did on the file on the vendors package.

Just to resume, create the method in the proper class that is being hit in your Controllers/Auth/ directory

27 Apr
3 weeks ago

Punksolid left a reply on Sum Total Price

@BEKASKAKI - I think that if service_transation table is the one that has the relationship to the service tables, you should have in your ServiceTransaction.php a belongsTo relationship

    public function service(){
            return $this->belongsTo('App\Service');
    }

    public function user(){
        return $this->belongsTo(User::class);
     }
    

And your show view has an edit use? because I dont see why to show all servicecategories and services. If they are not need it, you could retrieve all from your ServiceTransaction model

  public function show($id)
    {
    $service_transaction = ServiceTransaction::with(['user','service'])->findOrFail($id);
    /*And you will have $service_transaction->total*/

        $guest = RoomTransaction::with('room','guest')->find($id);
        $Service = ServiceCategori::all();
        $Services = Service::all(); //price from here
      
        return view('admin.'.$title.'.edit',compact('title','guest','Service','Services'));
    }


Is it possible to do this approach? why not?

As additional I recommend you to store the price also in service transaction, so if the price is updated the data will still be consistent.

Punksolid left a reply on More Than One Middleware For Route, Makes The Route Not Working

Hi @frumentius CORS is implemented primarily in web browsers. That's why it works on postman, the server is responding okey but because the response does not have the header in the response its blocking it right away.

So, instead of debugging where the middleware is failing I recommend you to use this package.

(https://github.com/barryvdh/laravel-cors)

Punksolid left a reply on Writing An Api In Laravel

Hi @aadhil Try to be more descriptive in your problem. Otherwise I will just recommend you this lmgtfy.com/?q=programing+api+laravel

Good luck

Punksolid left a reply on Sum Total Price

I think you could code it cleaner. I recommend you to use _id suffix in '$request->price'

$service = ServiceTransaction::make($request->all());
$service->user_id = Auth::user()->id;
$service->price = Service::find($input['price'])->price; // looks that you are saving the entire object, what are you trying to save?
$service->total = $service->price * $service->qty;
if (ServiceTransaction::create($input)){
            Alert::success('Successfully Updated', 'Success');
}else{
            Alert::error('Something went wrong!', 'Oops...');
}

return Redirect::to('admin/'.$this->title);

So It didn't work because its not saving or is it saving wrong data? (Check Service::find line) The database is saving all fields right? Is it saving ok but displaying it wrong?

Maybe the thing that its not right its in your show controller method. More info is needed.

26 Apr
3 weeks ago

Punksolid left a reply on Lenses

Hi @clifireri you will have more responses if you are more specific in the title name

Punksolid left a reply on Are There Any Cons Of Having More Then One Json Column In A Table

@NIKOCRAFT - Man! laraone looks awesome. With the context you said I will go for storing jsons because of the flexibility and as you say, properties table pattern looks harder to maintain.

I'm developing right now using mariadb 10.3.12 and at least this version allows json fields and json search with laravel, don't know about other functions.

I will follow other response of this thread, update us later which approach you used it.

25 Apr
3 weeks ago

Punksolid left a reply on Are There Any Cons Of Having More Then One Json Column In A Table

Hi @nikocraft it depends on what are you trying to achieve. The maintenance of those json object it could be a pain if you don't have things explicit or a proper handler.

Also, as it looks that you will use for something that will serve as a configuration of your app, it also could have some scripting inside, so take care.

Otherwise, I don't see why not to use it.

Punksolid left a reply on Forgot Password

Hi @zahidnazirkhan share the code

24 Apr
3 weeks ago

Punksolid started a new conversation Is It Viable To Make A CRUD Just To Add One Field To Serve As Only Read Relationship?

Hi, I want some feedback because I think something it's a little bit wrong here but I don't now the principles that it's wrong.

I have an SPA and there a form to create an object called Travel, and travel has 6 data fields and 7 relational fields, a couple of them are many to many relationships, I think its a little bit too much from an user interface perspective but its okey.

So the client asked if we add another field called Situation to the Travel form, that will be relational to Situation, and just have one String field, that will work as a tag. So with that I will need another crud and call the elements in the form to populate the select to relate to just one string field. There is no intention to list the related Travel models to a tag for now.

**Is it even right approach to do so? ** ** Is it that considered a bloated software? ** ** What are your thoughts to keep it the simplest? **

Punksolid left a reply on Feature: Abandon A Series!

what happens if you uncheck the only one episode you saw?