RoboRobok

RoboRobok

Member Since 3 Years Ago

Experience Points
25,010
Total
Experience

4,990 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
16
Lessons
Completed
Best Reply Awards
28
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.

Level 6
25,010 XP
Nov
06
1 week ago
Activity icon

Replied to Optional WHERE Statement In SQL Query

There is a cleaner way. Use when() method.

Activity icon

Started a new Conversation Sharing Homestead With The World

I'm looking for a way to share my local project with someone. Homestead offers sharing via ngrok with command:

share my-directory-name --region=eu

It works fine, but the limits are rather strict, with just 40 connections per minute. It's not enough for my project using real-time communication. I need more than 100 connections per minute.

Is there another free alternative? I found Serveo, but I'm not sure how to use it with Homestead.

I appreciate any advice.

Sep
03
2 months ago
Activity icon

Replied to How To Search Inside This Json

Great. I'm sure it will work for you then.

Activity icon

Replied to Laravel 6.0

Yeah, it doesn't even look like Laravel 5.9 to be honest. More like Laravel 5.8.1.0.

Activity icon

Replied to Book A Seance In Advance

I understand your question, but let me ask you one: isn't it possible to hire the bike 5 minutes before midnight and give it back after midnight, for example?

Activity icon

Replied to Meaning Of Cache:clear Config:clear

I'm not sure what is it that you don't understand. I assume you are a Laravel beginner, so the best path for you is to just get through the docs.

Activity icon

Replied to Is There Such Method In Collection?

Thanks! All I needed to know is that there is no built-in method in Collection.

I know the short closure syntax is coming to PHP 7.4. That wasn't the point of my question. I don't want to just simplify it no matter what, but to use built-in methods if they exist.

Activity icon

Replied to How To Search Inside This Json

So as you see, you don't work on Laravel 5.8. This whereJsonContains() method wasn't there back in 5.6, so it behaves just like whereWhatever() for you, which calls where('whatever', ...). Is it possible for you to update?

Activity icon

Replied to Is There Such Method In Collection?

My question is if the same thing can be achieved by some method of Collection via one-liner.

I'm trying to gain some fanciness here, you know...

Activity icon

Replied to How To Search Inside This Json

Can you run php artisan --version and tell me what you get?

Activity icon

Replied to How To Search Inside This Json

Can you show your code?

Activity icon

Replied to Maintenance Mode: How To Return A Json When Called /api/* Routes?

I would add a middleware checking if the app is down (app()->isDownForMaintenance()) and if it is, setting response to whatever you want.

Activity icon

Replied to How To Search Inside This Json

The link I posted is actually for Laravel 5.8. The docs design changed for all versions :)

Activity icon

Replied to Meaning Of Cache:clear Config:clear

cache:clear clears your application cache, no matter how it is configured (files, database etc.). It has nothing to do with configs.

config:clear deletes your cached config files. By default it's /bootstrap/cache/config.php. Laravel tries to read config from that file if it exists. Otherwise it reads your config from /config folder.

Activity icon

Replied to How To Search Inside This Json

Take a look here.

Activity icon

Replied to Get Group Members | Many To Many | Api | Prepare Response

And the problem is? Just set up your relations properly and then do something like:

$group = Group::find(3);
$members = $group->members()->paginate(10);
Activity icon

Replied to Laravel 6.0

Lies. It wasn't ready back when you replied but it is now :D

Activity icon

Replied to Vue Search Select With 16k + Options

Not sure about the newest trends, but I used to make this work with select2 JS library. It fetched n results from the API and injected them as the options for your <select>. In other words, you should make sure it's never too many options at once in DOM. Instead, while you type, the less and less are matching your criteria anyways.

Activity icon

Replied to How To Search Inside This Json

Your JSON is not what you want. It should be ["masterResearchDomains","masterResearchDomains2"], not ["masterResearchDomains,masterResearchDomains2"].

Activity icon

Replied to Is There Such Method In Collection?

I gave you example of the map() call doing the same thing, I still need to give you the result? Okay, so it is:

[
    {"animal": "dog"},
    {"animal": "cat"},
    {"animal": "tiger"}
]
Activity icon

Replied to How To Authenticate Incoming Requests From Node To Laravel Application Using Middleware And Passport ?

I would consider using Laravel Passport, which is just a wrapper for OAuth 2.0. The concept of expiring tokens is well-suited for app-to-app communication.

Sep
02
2 months ago
Activity icon

Replied to Show Date In The Top Bar? PHP Or JS?

PHP. Server's date is more reliable than client's date.

If you want to make it dynamic (i.e. make the clock tick), create new Date object in JS, but construct it with server's time.

Activity icon

Started a new Conversation Is There Such Method In Collection?

I need to replace each array entry to ['column' => $value]. Is there such method in Laravel's Collection?

For now I do it as:

$animals = collect(['dog', 'cat', 'tiger']);

$columnized = $animals->map(function (string $animal): array {
    return ['animal' => $animal];
});
Activity icon

Replied to Checking Both Roles & Permission At The Same Time

I mean situation when each role has their own dashboards. I understand your point and I agree that permission-driven system is better in most cases, just like feature checking is better than browser checking. But there are exceptions. Adding artificial permissions (like view_editor_dashboard) just to follow this rule is not the greatest idea. As well as checking multiple permissions to guess what is the user's context.

Activity icon

Replied to Checking Both Roles & Permission At The Same Time

In my opinion, can() is better when we want to check permission to do something, but checking entire role also makes sense in some cases. For instance, if we want to display entire dashboard area, it sometimes more sense to show/hide it through roles instead of checking individual permissions, which in theory are more dynamic.

Activity icon

Replied to Terrible Scrolling Experience On Laravel.com

I would be seriously glad to know what is the purpose of these scrolling scripts though.

Sep
01
2 months ago
Activity icon

Replied to Terrible Scrolling Experience On Laravel.com

Im talking about laravel.com, not laracasts.com.

But I do agree about the pagination.

Activity icon

Started a new Conversation Terrible Scrolling Experience On Laravel.com

As we all probably know, laravel.com changed the design recently. While I feel like its a downgrade from previous version, one feature in particular drives me nuts.

On mobile, laravel.com now delivers awful scrolling experience. All of the glide is gone in favor of some manual JavaScript scrolling nightmare. Its not even smooth.

Whats the point of these scripts? Whenever I find one of these on any website, Im like: nooo. Does anyone really prefer that over native scrolling?

Aug
28
2 months ago
Activity icon

Replied to Parallax Animation In Vanilla Javascript

Translate and translate3D don't work on inline elements. Set display: inline-block on your <span>s.

And as for "Hello World" not moving, it actually does :) You can see that it doesn't scroll along with the window, because it translates proportionally to vertical scroll position, giving the position: fixed effect. Try changing data-rateX="1" to something else and you will see it moving.

Activity icon

Replied to Using DB_HOST=192.168.10.10 On Homestead

We use Docker in my current project, but I hate it. It drains my MacBook's battery in less than 4 hours, but I guess it's also fault of poor machine configuration.

Activity icon

Replied to Using DB_HOST=192.168.10.10 On Homestead

If you think about it, it is no different than any remote host.

I agree.

Why do you prefer Valet over Homestead? I used Valet just a tiny bit.

Activity icon

Replied to Can The Shopping Cart Designed Like This

I think it would be nice to default your Cart's behavior to current user. So, for logged out user, it would read session. For logged in, it would be the database.

You would also need the logic to move Cart's content from session to database and (perhaps) vice versa. That can be nicely done using Events during login and logout behavior.

If I am logged out and put something to my cart, then log in, I would expect my session cart to get merged with my database cart.

If I am logged in, put something to the cart and then log out, I would say it makes more sense to keep the session cart empty.

Activity icon

Started a new Conversation Using DB_HOST=192.168.10.10 On Homestead

Hi guys,

is there any potential trap using DB_HOST=192.168.10.10 on Homestead? I've always thought that I need to do any migrations, seeds etc. through SSH in Homestead, but I just found out that setting database host to 192.168.10.10 gets rid of that inconvenience, which is awesome, because I hated this additional step.

Do you guys use 192.168.10.10 as well?

Jul
10
4 months ago
Activity icon

Started a new Conversation How To Run My Own PHP Script On Homestead Provision?

I made a script generating Homestead.yaml based on my projects folder tree. What it does is basically mapping folder name to its *.test domain, using either /public folder (if it exists) or folder root. It works great, coupled with dnsmasq I no longer need to register any projects in hosts nor Homestead.yaml manually.

The next step would be to run this script automatically during Homestead's provision. Is that possible? Or maybe it's even possible to do it in more fancy way? I'd like to just make sure all my folders work with their domain and Homestead config, because of certificates, doesn't support any wildcard syntax.

Jul
04
4 months ago
Activity icon

Replied to How To Implement Remember Me Functionality By Laravel Passport?

Dont get too crazy with these security topics. Implicit grants are insecure. Local storage is insecure. Life is insecure.

Activity icon

Replied to How To Implement Remember Me Functionality By Laravel Passport?

I wouldnt use an app where I need to log in every single time.

Activity icon

Replied to Best Place In Project To Define Query Scope If There Is No Model?

If you want to put it inside a controller, I'm assuming there is only one page using it. You can just place this login inside your controller action if it's not useful anywhere else.

Activity icon

Replied to How To Implement Remember Me Functionality By Laravel Passport?

@bobbybouwmann what do you mean by session? PHP session or session storage? Because PHP session is just data linked to a cookie, nothing more.

For remember me to work, Id say the best place to keep the token in is local storage. Cookies are by design not the best to work with APIs, as they are automatically sent by the browser no matter what.

Activity icon

Replied to Hash Validation And Password Problem

Why wouldn't you add a custom validation rule?

Activity icon

Replied to How Often Would I Refresh The Offline Access Token In A Web App?

However every time you request a new access_token using the refresh_token you also get a new refresh_token, so this should cover that.

This is actually not true. The only time you get a new refresh token is when you exchange the authorization code, which was obtained by accepting a consent screen with offline access being explicitly requested. You cannot get a new refresh token without user interaction, at least with Google API, but I believe thats part of OAuth 2.0 protocol. Refresh tokens are too sensitive and giving them out with every new access token request would have been a security trap.

Jul
03
4 months ago
Activity icon

Replied to How Html Developer Can Work With Live Site?

So what if the basics didn't change? It has nothing to do with anything really. Some quirky logic behind your thinking pattern here.

Activity icon

Replied to How Html Developer Can Work With Live Site?

You argue here like it was your first week of programming.

Activity icon

Replied to Paginate BelongsToMany Relationship Records If More Than Set Limit

You almost made it:

$posts = $category->posts()->paginate(20);

Any Query Builder in Laravel has access to paginate() method and relationship called as a method behaves like a Query Builder.

Relationship called as a property is Eloquent Collection, which doesn't have paginate() method.

Activity icon

Replied to Get Distinct Eloquent Relation Data Count And Records In Laravel

All is correct, I'm only not sure about the 3rd point:

3rd : we slice the array from index 0 to the random number generate and so we get a unique length for the array for each post category.

Not sure what you mean by unique length. What this line does, is just cutting the array to make it of random length between 1 and n, where n in your case is 27.

Let's consider this example of 5 instead of 27, for simplicity:

$categoryIds = range(1, 5);
// [1, 2, 3, 4, 5]

shuffle($categoryIds);
// let's say it's now [3, 1, 4, 5, 2]

$categoryIds = array_slice($categoryIds, rand(0, count($categoryIds) - 1));
// this line will do anything between array_slice($categoryIds, 0) and array_slice($categoryIds, 4), which means:
// array_slice($categoryIds, 0) => [3, 1, 4, 5, 2]
// array_slice($categoryIds, 1) => [1, 4, 5, 2]
// array_slice($categoryIds, 2) => [4, 5, 2]
// array_slice($categoryIds, 3) => [5, 2]
// array_slice($categoryIds, 4) => [2]

I hope it's crystal clear now :)

Activity icon

Replied to Get Distinct Eloquent Relation Data Count And Records In Laravel

The fact that you limited your random entries to 3 doesn't mean it will never duplicate. Please use the code I posted above.

Using composite primary keys is a great idea. It uses an array:

$table->primary(['category_id', 'post_id']);

Remember about setting up foreign keys as well.

Activity icon

Replied to How Html Developer Can Work With Live Site?

The problem is that you will go nowhere with the basics of programming today, as far as web development is considered. This is because of the background.

It's just like building a house. Was it easier or harder to build a house 5000 years ago? You can say it was harder, because there were less materials available. And you are right - if was more difficult to build a house 5000 years ago. But it's only true for a house standard of 5000 years ago.

Same goes with websites. You can build a simple, static page today and it will be easier than it used to be. But your website will be nowhere near expectations of web user in 2019. And I believe this is how it should be put.

Activity icon

Replied to Get Distinct Eloquent Relation Data Count And Records In Laravel

If you want to generate random unique numbers, you can do it like this:

$categoryIds = range(1, 27);

shuffle($categoryIds);

$categoryIds = array_slice($categoryIds, rand(0, count($categoryIds) - 1));
Activity icon

Replied to Get Distinct Eloquent Relation Data Count And Records In Laravel

I see. To be honest, this is where I'd make an assumption that these pairs are unique and improve my faker to follow that rule. Placing a UNIQUE index is a great idea too.

Remember that sometimes it's good to have assumptions about your code/data quality instead of trying to make your code adaptable to all circumstances. You will thank me later :)

Activity icon

Replied to Forbidden Access For Portion Of My App From Phone + Tablet

Can you start from justifying why? Why would you restrict access on mobile/tablet?

Also, what is that part of the app that you want to hide? Is it just an element or entire route?

Activity icon

Replied to Get Distinct Eloquent Relation Data Count And Records In Laravel

What do you mean by distinct? You have duplicates in your pivot table? Is there a reason for that? If not, I would clean the database and put a UNIQUE index of this pair in the pivot.