vedmant

vedmant

Member Since 3 Years Ago

Chicago

Experience Points 3,765
Experience Level 1

1,235 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 58
Lessons
Completed
Best Reply Awards 0
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.

09 Jul
2 years ago

vedmant left a reply on How To Add Middleware To Middleware Group Based On Enviroment

@JMarcher No, it will not work, you don't check for environment like $this->app->environment('local') it will not work in constructor because application is not booted when kernel is instantiated and attempt to get environment will cause error. This is what I told in previous comment.

20 Jun
2 years ago

vedmant left a reply on How To Add Middleware To Middleware Group Based On Enviroment

@JMarcher Nope, it doesn't work, I can't get environment from $this->app->environment(), it throws weird error. I ended up putting it to RouteServiceProvider.php

    /**
     * "api" middleware group
     */
    $api_middleware = ['throttle:60,1', 'api_response'];
    // Local and development enviroment middleware to groups
    if ($this->app->environment('local') || $this->app->environment('development')) {
        $api_middleware[] = 'api_debug';
    }
    $router->middlewareGroup('api', $api_middleware);

vedmant started a new conversation How To Add Middleware To Middleware Group Based On Enviroment

Hi, I have one issue with middlewares, I want to add my custom middleware to "api" middleware group, but only for development and local environment, but in Kernel.php all groups statically typed in the property protected $middlewareGroups = []; Is there a was to add/edit group middleware dynamically?

07 Jun
3 years ago

vedmant left a reply on The Best Way To Cache Laravel Policies

Yeah, I've done pretty the same, the point was to do it without changing every policy method. To keep policies clean, without extra cache code in every method.

05 Apr
3 years ago

vedmant started a new conversation The Best Way To Cache Laravel Policies

Hi, I have situation when I have many to many relations between users and groups and pivot table has type column that can have either 'admin' or 'participant' value. The problem here is that I need to pull pivot table record on every policy check to get this type field. And when I use @can() directive in templates it generates tons of the save queries. Is there a good simple way to add caching to Laravel Policies? So it will run actual policy method only once.

28 Mar
3 years ago

vedmant left a reply on Log In With Username Or Email In Laravel 5...

@betog Yes, right, you can find this method in AuthenticatesUsers trait but you overload this method with method in your AuthController, cause AuthenticatesUsers is part of Laravel framework, but AuthController if part of your application.

08 Oct
3 years ago

vedmant left a reply on Log In With Username Or Email In Laravel 5...

I used this approach, overloaded two functions:

/**
 * Get the login username to be used by the controller.
 *
 * @return string
 */
public function loginUsername()
{
    return 'login';
}

/**
 * Get the needed authorization credentials from the request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return array
 */
protected function getCredentials(Request $request)
{
    $login = $request->get('login');
    $field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';

    return [
        $field => $login,
        'password' => $request->get('password'),
    ];
}

As for me this looks cleaner.

03 Oct
3 years ago

vedmant left a reply on L5 Extending Guard Object In Authentication Framework

I have this problem as well, it looks like to extend Guard class you need to do following:

Make your own version of the AuthManager class, and change references to Guard to your own extended version of Guard, replace Guard class with MyGuard.

/**
 * Create an instance of the Eloquent driver.
 *
 * @return \Illuminate\Auth\Guard
 */
public function createEloquentDriver()
{
    $provider = $this->createEloquentProvider();

    return new MyGuard($provider, $this->app['session.store']);
}

You can also edit other functions for different drivers, like "protected function callCustomCreator($driver)", "public function createDatabaseDriver()" and everywhere it have to be MyGuard.

Then Make your own version of the AuthServiceProvider, and change the reference to AuthManager to the version you just created.

Personally I don't understand why it was done so hard to extend, as for my Guard class is the main working class for Auth module, so it have to be extendable easily, but instead you almost have to rewrite whole package.

vedmant left a reply on Complexity Of The Code Of Laravel And Its Performance

@dberry I wouldn't say it's flexible, flexibility is when you can easily change anything in existent code, in this case it's very complex, to change package you first have to learn how it works in all details, check all dependencies, this is not flexible, this is very time consuming, especially when each package is written it's own way. For me, flexible means simple in the first place, when code is simple and fast to learn, it will be flexible as you can rewrite or extend it much faster.

vedmant left a reply on Complexity Of The Code Of Laravel And Its Performance

@pmall That works, but you can't disagree that this approach is quite complex and different for each component, there is no one solution to extend any package. All packages are written differently and require different approach, most of them will require replacing with own service provider, digging into whole package code and extend all dependable classes, this takes hours. That's why for me Laravel looks not like framework, but more like container for different packages. In my understanding, framework means working in some specific frames so any component should be written with particular and only one structure, in this case each component is more like own application, that provides some connectors to work with Laravel.

01 Oct
3 years ago

vedmant left a reply on Complexity Of The Code Of Laravel And Its Performance

@sid405 You didn't get at all what I'm talking about, I'm talking about complexity of code, and even if you need just to edit one small line in code class, you will need to copy or rewrite half of existence module. For example in Kohana Framework, I worked before, all you need is just place a file, extend needed class and method and that's all, you can extend any core method just in few minutes. In case of Laravel I was debugging it for hours until I found how needed me Class is instantiated and how many other files and classes I need to rewrite just to extend one method in one class.

If to speak about interfaces and own package instead. For example I wanted to make it use single users tokens table for multiple purposes, like email confirmation, remembered tokes, reset passwords, change email, so on. And starting from this point it's up to impossible to extend existence Auth package. For instance if you try to extend UsersTokenRepository that uses TokenRepositoryInterface that in its turn defines other interfaces for methods properties, so I need to extend this interface because it's type hinted in PasswordBroker class, then the same way it linked to other classes and interfaces. So what I'm talking about, that I need to extend and replace almost each of package classes, interfaces. It will be or just almost full copy of original package with only some parts changed, or I just need to create my own new one. It means that this is just not extendable code.

If you know something about oop concepts, just tell me how to extend method in UsersTokenRepository::create, and make $user nullable (just remove CanResetPasswordContract). I can already tell you that it will require to replace interface and class itself, replace service provider and use new created class in it. And this is just one method, try to extend Guard class from Auth package.

vedmant left a reply on Complexity Of The Code Of Laravel And Its Performance

I agree, sometimes it just blows my mind when I'm trying to extend some default packages like Auth, it's written in a such a complex was that to extent it I just need actually to write fully my own package for Auth functions, because there are everything is too closely tied together with interfaces. For example, try to remove remember_token field from users database table, and it will stop working, you will need to overwrite Guard class, to overwrite Guard class you need to create your own Service Provider, you will need to create your own AuthManager and change user Guard class. But to know all this you first need to debug and to read whole Auth module code. This is really too much as for me, it just forces to write own custom modules.

25 Aug
3 years ago

vedmant left a reply on Using Auth In Service Provider To Get User Object

I have the same problem here, it looks like Auth::user() function can't get session data (where user id is stored) because session is started only after all service providers are booted in StartSession middleware. So if you need to know if user is logged in there is no way to do this from ServiceProvider, only from Middleware.

30 Jul
3 years ago

vedmant left a reply on 'Real Life' L5/L5.1 App Example

Checked this "invoice-ninja" project, it's written mostly in a bad way, just look into routes file http://screencast.com/t/8EO1eFcZvJZ , they have put there tons of definitions, list of credits cards vendors http://screencast.com/t/hQtSfSTb , some functions. I would recommend not to get this project as an example of clear code. Also they never use Requests validations, while I was scrolling code I noticed tons of possible bugs, like using route resource on one function http://screencast.com/t/OFnqYW9Ame , they have to replace it with Route::post , and so on. Also this project don't use any custom Service providers, some wierd files http://screencast.com/t/oC1ImxfA1lh with wrong opening tag and not PhpDoc commets. So don't get this project as an example.

27 Jul
3 years ago

vedmant left a reply on I Got Error On Php Artisan Migrate

I just had the same problem. The problem is that your script is launched by php, but it needs php-cli. I fixed in creating new dir ~/opt/bin, linking php-cli there as just php, and adding this dir to $PATH variable as prepending others.

something like this commands: mkdir ~/opt/bin ln -s /usr/loca/php56/php-cli ~/opt/bin/php echo $PATH=~/opt/bin/php:$PATH > ~/.bashrc

(didn't check commands)