RoboRobok

RoboRobok

Member Since 3 Years Ago

Experience Points 17,460
Experience
Level
Lessons Completed 16
Lessons
Completed
Best Reply Awards 21
Best Answer
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.

18 Dec
1 day ago

RoboRobok left a reply on How To Edit Vagrantfile For Homestead?

Unfortunetely it didn't help. Maybe the machine should be restarted?

17 Dec
2 days ago

RoboRobok left a reply on How To Edit Vagrantfile For Homestead?

I'm installing VirtualBox Guest, I've heard it can help too. Nobody experienced 100%+ CPU usage with Homestead recently? The fan is making me crazy, it's works hard all the time.

16 Dec
3 days ago

RoboRobok left a reply on How To Edit Vagrantfile For Homestead?

That's what I think too, but I still have no idea how to pass these variables. Homestead is not documented too well.

11 Dec
1 week ago
10 Dec
1 week ago

RoboRobok left a reply on Require_if Other Field Contains Some Value

Check out sometimes() method. I'm not sure if it's available for 5.3 though.

RoboRobok left a reply on Very Weird Behavior On Deleting A Model

Why won't you just do it like this?

$user->comments()->delete()

It will be faster, because it creates one database query per model type. Your way makes n queries, where n is the number of entities.

RoboRobok left a reply on Connect Website To Other Database Server

Just set the appropriate database host.

RoboRobok left a reply on Sort By Default On Name ASC Using Kyslik\ColumnSortable\Sortable

The documentation clearly says how to do it:

You can set default sorting parameters which will be applied when URL is empty.

$users = $user->sortable('name')->paginate(10);
// produces ->orderBy('users.name', 'asc')

$users = $user->sortable(['name'])->paginate(10); 
// produces ->orderBy('users.name', 'asc')

$users = $user->sortable(['name' => 'desc'])->paginate(10);
// produces ->orderBy('users.name', 'desc')

RoboRobok left a reply on Why Is Telescope Service Provider Auto-discovered?

I think this is not possible. Auto discovery is there since Laravel 5.5 and Telescope requires Laravel 5.7.7. I thought it’s some caching thing or just a forgotten thing. Maybe they decided later to add service provider manually (to make it easy to have local-only Telescope) and forgot to change the legacy code?

RoboRobok left a reply on HTML5 Validation Multiple Forms

The reasons are not enough to use multiple forms, it’s almost never a good aproach to use multiple forms doing the same thing. The design problem is not a real problem :) You can still achieve the same layout using single form.

RoboRobok left a reply on HTML5 Validation Multiple Forms

I have a feeling that your code needs a redesign.

RoboRobok left a reply on HTML5 Validation Multiple Forms

Why are they separate forms?

RoboRobok left a reply on HTML5 Validation Multiple Forms

@andreich1980 is correct. That's the first problem here.

Are you validating just the first form and then clicking button on every form, depending whether the first form is valid or not?

RoboRobok started a new conversation Why Is Telescope Service Provider Auto-discovered?

In Laravel Telescope, its main Service Provider is being auto-discovered:

"extra": {
    // ...
    "laravel": {
        "providers": [
            "Laravel\Telescope\TelescopeServiceProvider"
        ]
    }
},

I don't really get it why, because the installing script (php artisan telescope:install) adds the child service provider to the config/app.php:

file_put_contents(config_path('app.php'), str_replace(
    "{$namespace}\Providers\EventServiceProvider::class,".PHP_EOL,
    "{$namespace}\Providers\EventServiceProvider::class,".PHP_EOL."        {$namespace}\Providers\TelescopeServiceProvider::class,".PHP_EOL,
    $appConfig
));

This child service provider extends the auto-discovered one:

use Laravel\Telescope\TelescopeApplicationServiceProvider;

class TelescopeServiceProvider extends TelescopeApplicationServiceProvider

My question is, what is the point of auto-discovering the parent service provider if we are manually registering its child anyway?

RoboRobok started a new conversation How To Edit Vagrantfile For Homestead?

Hi guys, I'm getting 100% CPU usage from VBoxHeadless process. After some research, it turns out this setting in Vagrantfile should help:

$enable_serial_logging = false

How do I change this in Homestead? Should I put it to Vagrantfile or Homestead.yaml? And which lines exactly?

07 Dec
1 week ago

RoboRobok left a reply on Can I Use Eloquent's Count() With GroupBy()?

@petrit This is not the same thing. Like @talinon said, if you have many records, it will be very slow.

RoboRobok started a new conversation Can I Use Eloquent's Count() With GroupBy()?

I would like to count games by is_released flag. I did it like that:

Game::select('is_released', DB::raw('count(*)'))
    ->groupBy('is_released')
    ->pluck('count(*)', 'is_released');

Another way to express the same thing is:

Game::select('is_released')
    ->selectRaw('count(*)')
    ->groupBy('is_released')
    ->pluck('count(*)', 'is_released')

It works, but can it be simplified, using Eloquent's count() method instead of DB::raw() or selectRaw()? (I'm just curious)

27 Nov
3 weeks ago

RoboRobok left a reply on Set Vue Component As 'default'

Just go through Vue.js basics, I don't see why would anyone repeat after tutorials. The answer to your question should be in the first paragraph of any tutorial.

RoboRobok left a reply on Laravel New Files Missing Index.html, Index.php, And .htaccess

The root of Laravel app is in /public folder, so some other things like /config, /storage, /vendor etc. are higher in the directory tree than your index.php. Your domain should be pointing at the /public folder. /public/index.php is where it all starts :)

RoboRobok left a reply on Parent With Children Tree In Blade

Check out Recursive Array Iterator.

By the way, isn't <optgroup> limited to one nesting level?

RoboRobok started a new conversation OAuth 2.0 And Requesting New Scopes

Hi guys, I'm learning Laravel Passport and OAuth 2.0 in general.

I remember a while ago I have seen some articles stating that it's better to request permissions late. In other words, at first just ask for basic permissions (scopes) and then ask for more progressively, if someone in fact wants it. I agree with such approach. Giving user too long list of permissions can be overwhelming.

The question is, how does Laravel Passport support this? I have played around a little and I see that if you request different scopes for the same client, it generates new another access, but ignoring previously granted permissions. Also, consent screen doesn't skip previously granted scopes.

So, is requesting new scopes unsupported in Laravel Passport? How do other OAuth 2.0 implementations solve this? Do they combine multiple access tokens (I doubt it), or maybe allow to pass existing access token to the consent screen displaying only the new scopes, but saving all scopes from both? It's really interesting.

26 Nov
3 weeks ago

RoboRobok left a reply on OrderBy Not Sorting

Install Laravel Debugbar and see what is the SQL query to get the articles.

RoboRobok left a reply on OrderBy Not Sorting

Maybe your pos is a string in the database? Your code looks good.

RoboRobok started a new conversation Why Is This Validation Still Returning The Results?

In Laravel Passport, there is a method to add new OAuth client via POST /oauth/clients:

public function store(Request $request)
{
    $this->validation->make($request->all(), [
        'name' => 'required|max:255',
        'redirect' => 'required|url',
    ])->validate();

    return $this->clients->create(
        $request->user()->getKey(), $request->name, $request->redirect
    )->makeVisible('secret');
}

The weird part is that if validation fails, the list of existing clients is being returned, just like what GET /oauth/clients does. If I catch the exception, I see it's an instance of Illuminate\Validation\ValidationException, as expected.

How is it possible that the validation exception is translated to this?

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

It's not the first time when I'm surprised with Taylor's answer. Sometimes he defends obvious core bugs on GitHub. Maybe he's tired with Laravel already.

RoboRobok left a reply on RetrieveByCredentials Method

To make it work in different way than built-in providers, which are database and eloquent, you need to create custom provider, as @d9705996 linked to.

These built-in providers just match key/value array with database columns, but ignoring the password key.

RoboRobok left a reply on Sublime Text And .editorconfig

@coder81 yes, Sublime Text requires a plugin to work with .editorconfig. Without a plugin, this file just does nothing.

From Package Manager, search for EditorConfig plugin. It works just fine, I tested myself :)

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

I asked Taylor on Twitter and his response was:

It already uses type hints

Sometimes I don't understand his thinking pattern. Maybe by "hints" he really means "hints", not the language feature of type-hinting.

Lack of type hints is obvious in Laravel, like here:

function tap($value, $callback = null)
{
    if (is_null($callback)) {
        return new HigherOrderTapProxy($value);
    }

    $callback($value);

    return $value;
}

Callable is not even type hinted, just used with parentheses.

24 Nov
3 weeks ago

RoboRobok left a reply on Is HTTP To HTTPS Safe?

I’m asking just for educational purposes.

RoboRobok started a new conversation Is HTTP To HTTPS Safe?

Hi guys, if I make a request from HTTP to HTTPS, are my request headers and data encrypted? And the other way, from HTTPS to HTTP?

And how about response headers and data for HTTP to HTTPS and the other way?

23 Nov
3 weeks ago

RoboRobok left a reply on Error In Edit Page

Check out var_dump(compact('article')) and see if you are using any arrays directly as strings.

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

A little speculation never killed no one :D

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

These tests are not that great probably, because I used to see core methods failing in the middle because of missing contract methods.

I do agree that there are cases where no type-hints is the only way do go in PHP, but my question is about avoiding them entirely, not about some single cases, which I am aware of.

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

@martinbean that is possible. I wonder if it's planned to introduce type hints or not. I personally feel so much safer when they are on place ?

RoboRobok left a reply on Why Isn't Laravel Core Still Type-hinted?

I'm not sure if that is an explanation why there are no type hints at all. But yeah, I wish PHP supported real method overloading, that would be great. In those single cases, of course we can't have type hints currently, but Laravel often type-hints some contract in the comments, but the code itself is not type-hinted.

RoboRobok started a new conversation Why Isn't Laravel Core Still Type-hinted?

Newest Laravel requires PHP 7.1.3. Primitive type hinting is there for a while, but Laravel core still doesn't use it. Even Symfony has its core type-hinted now.

I create this topic to understand if there is any potential benefit of avoiding type hints. In my opinion, the lack of them lead to bugs that are difficult to track. Laravel core uses type hinting only for arrays and sometimes Closures. Several times, I have seen code that was buggy, because the type wasn't checked prior to using the variable. So a method pooped in the middle instead of at the beginning.

29 Oct
1 month ago

RoboRobok left a reply on How To Assign Temporary Data To Eloquent Model?

In my opinion all of these solutions are only good for tiny projects. In real world, you keep passing models here and there to limit database queries. Temporary values are not great as model attrobutes, as these should be reflected in database schema.

Any other ideas?

22 Oct
1 month ago

RoboRobok left a reply on How To Assign Temporary Data To Eloquent Model?

sfz0311 your answer is wrong on mamy levels.

Can anyone who actually knows Laravel help?

RoboRobok left a reply on How To Assign Temporary Data To Eloquent Model?

A method to be used for one single calculation used in one place? I don’t think that’s any good.

RoboRobok started a new conversation How To Assign Temporary Data To Eloquent Model?

What is the best place for temporary Eloquent Model data? Let's say I need to compute something on each Eloquent Collection entry. Something that doesn't exist in the model itself and needs to go to the view, but defining getXxxAttribute doesn't make sense, because it's used only by one view.

Also, I like to avoid assigning properties to a model directly, because it will screw up potential update:

$dog->totalWeekendsAlive = $totalWeekendsAlive;
// ...
$dog->save(); // will cause problem, because totalWeekendsAlive is not a valid property

I usually use setRelation() method, but I'm not sure if that's very neat:

$dogs->each(function (Dog $dog) {
    // $totalWeekendsAlive = ...;
    $dog->setRelation('totalWeekendsAlive', $totalWeekendsAlive);
});

And then I'm just getting this value like this:

{{ $dog->totalWeekendsAlive }}

Is there any cleaner way? I could make a separate variable with these, but it would be nice to have it in the model object itself for this case.

06 Sep
3 months ago

RoboRobok started a new conversation Why Are Cached Routes Serialized And Base64 Encoded?

I just found out that /bootstrap/cache/routes.php contains the following code:

app('router')->setRoutes(
    unserialize(base64_decode(''))
);

I'm surprised to see unserialize and base64_decode in a cache file, I thought these are functions are rather slow?

Do you guys know why was it chosen to use that method instead of just generating a PHP file like config cache does?

12 Aug
4 months ago

RoboRobok started a new conversation How To Handle Event Listeners In Single Page Application?

Hi guys,

how do you nicely handle event listeners in Single Page Applications? The problem is not really a problem for clicking, mouse hovering etc., because the elements will just be removed from the DOM along with their listeners. What about the keyboard events though?

Let's say my SPA has multiple different galleries which behave a little differently. Each supports arrow keys though.

Do front-end frameworks handle removing event listeners? What is a fancy way to do it? For my understanding, when another page is being loaded or, even better, when my element is being destroyed, the event listeners could go away. Is it common to have a destroy callback, where such actions would take place? The listeners would need to be remembered before, because we need to explicitly say which ones need to be removed, right?

Can you share some nice architectural ideas to do it?

06 Aug
4 months ago

RoboRobok left a reply on Assumptions In The Code

Using a name like sortedSomething is great approach. I would like to see how these kind of situations are handled in large scale apps.

I tend to overvalidate things, which sometimes ends with validating one value multiple times. I'm not proud of it.