pdc

pdc

Member Since 2 Years Ago

Experience Points 280
Experience Level 1

4,720 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 0
Lessons
Completed
Best Reply Awards 0
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.

15 Aug
1 month ago

pdc left a reply on Urgent Whoops

@robstar I don't think anyone's interested in experience points for this pathetic framework. It would only lower their credibility.

@mthomas Developers and companies don't rely on frameworks where credentials end up in a http response. It's a great indication of what's inside the box. The company I'm working at doesn't want to use this framework because they think it's run by amatures because of this behavior.

13 Aug
1 month ago

pdc left a reply on Urgent Whoops

I wish there was a two to four year apprenticeship program before anyone could start writing an MVC framework... At least then they'd know that credentials show not be echoed in an HTTP response. Luckily people learn... Well, most of them

12 Aug
1 month ago

pdc left a reply on Urgent Whoops

You can't expect an amature MVC framework to follow the OWASP guidelines... So if you don't like this, you better choose a good framework

18 Jun
2 months ago

pdc left a reply on Why Experienced Developers Consider Laravel As A Poorly Designed Framework?

Well there is a clear difference. Laravel is the very first and only "framework" that prints environment variables in debug pages... Very unique in any way. It's the exact reason why professional companies don't even consider using this framework...

19 Oct
10 months ago

pdc left a reply on Eloquent Query Picking Wrong Database For The User Model

Excuse me. I've put the table variable into my model and now my query indeed looks like it should. Thanks for the suggestion, it appears to be working now.

Why isn't it enough to define the $connection? It actually includes the database name...

18 Oct
10 months ago

pdc left a reply on Eloquent Query Picking Wrong Database For The User Model

That does not explain why Laravel is looking for the users table in the wrong database... It's the essence of the issue.

After this, i'm also planning to use this permission system to authorize the requests.

pdc started a new conversation Eloquent Query Picking Wrong Database For The User Model

I'm currently setting up my own role-based access-control-system on my website.

You can add Entities (eg. an Artist).
        |
    permissions
        |
You can add Roles (eg. Administrator, Blogger, Developer).
        |
    role_user
        |
The users are located within another database (the Internal database) in order to reuse the authentication

I'm able to assign a role to a user (eazy peazy), to assign a permission for an entity to a role (eazy peazy).

But when I'm trying to check the permission for a user, odd things happen.

config/database.php

mysql       ->  MusicDemons
mysql_auth  ->  Internal (contains the users-table)

User-model

protected $connection = 'mysql_auth';

Code to check if the current user has permission to do something with the Entity

$result = 
    Entity::where('model_name','=',$model_name)
        ->whereHas('permissions', function($query) use ($action) {
            $query->where($action,'=',true);
            $query->whereHas('allowed_users',function($query){
                return $query->where('id','=',Auth::user()->id);
            });
        });

dd($result->toSql());

This code is being called through a webroute, for testing purposes

Route::get('test',function() {
    $perm = App\Helpers\RbacPermission::has_permission('App\Entities\MusicDemons\Artist','create');
    dd($perm);
});

You can see the result of this query in action at https://musicdemons.com/test

The raw SQL query is: select * from entities where model_name = "App\Entities\MusicDemons\Artist" and exists (select * from roles inner join MusicDemons.permissions on roles.id = MusicDemons.permissions.role_id where entities.id = MusicDemons.permissions.entity_id and create = '1' and exists (select * from users inner join MusicDemons.role_user on users.id = MusicDemons.role_user.user_id where roles.id = MusicDemons.role_user.role_id and id = '1') and roles.deleted_at is null) and entities.deleted_at is null

For some reason the eloquent query is picking the wrong database for the User-model (read: users.id doesn't have the database prefix and should actually be Internal.users.id). The odd thing is that the User-model has the $connection explicitly defined, and anyway picks the wrong database to select the data from!

How do I solve this problem? In my opinion this is a bug in Laravel... but is there a way around this bug?

The entire project is hosted at https://github.com/PieterjanDeClippel/LaravelProjects .

The Internal project is just to manage the database containing the users and password_resets. The MusicDemons project contains the main project.

10 Aug
1 year ago

pdc started a new conversation How Do I Send An E-mail Through SMTP

I'm trying to send mails through the mailhub of my Internet Service Provider (Telenet). Previously, I've done the same using the simple-smtp linux package.

The configuration was as follows:

[email protected]
mailhub=smtp.telenet.be:587
rewriteDomain=example.com
hostname=example.com
UseTLS=YES
UseSTARTTLS=Yes
AuthUser=[email protected]
AuthPass=your_password
AuthMethod=LOGIN
FromLineOverride=YES

To make this successful, I also had to set up following reverse aliases in sSMTP. For each Linux user who wants to send emails - let's say www-data since that's the user that runs the webserver.

root:[email protected]:smtp.telenet.be:587
pi:[email protected]:smtp.telenet.be:587
no-reply:[email protected]:smtp.telenet.be:587
www-data:[email protected]:smtp.telenet.be:587

I've already set up my environment file with the credentials to connect to the Telenet mailhub. This works as expected. However, PHP complains about missing reverse aliases.

Expected response code 250 but got code "550", with message "550 5.1.0 <[email protected]> is not an alias of [email protected]"

Where can I set up these reverse aliases to allow the www-data user to send emails on behalf of [email protected]

16 Jan
1 year ago

pdc started a new conversation Laravel Localization For Long Strings

I have a Laravel website with views containing long, static strings. From the documentation (https://laravel.com/docs/5.2/localization) I understand you can use App::setLocale($locale) and App::getLocale() to change the locale. However, since my views contain long strings (mainly parameterless), I don't see how it would be handy to paste all these texts into /resources/lang/{locale}/messages.php-file. I assume this would get very confusing very fast. How do you deal with this?

25 Nov
1 year ago

pdc left a reply on Sync Pivot-table With Additional Columns

Well never mind. I've arrived on this page: https://laracasts.com/discuss/channels/laravel/sync-with-array-data-and-pivot And I was able to implement it successfully.

pdc started a new conversation Sync Pivot-table With Additional Columns

I'm trying to update additional columns on a pivot-table. I have a model "Person" and "Artist". There's a many-to-many relationship between them. The pivot-table contains a column named "active". This is the one i'm trying to set, and determines whether or not a person is still in the band.

class Artist extends Model {    
    public function members() {
        return $this->belongsToMany('App\Entities\Person')->withPivot('active');
    }
}
class Person extends Model {
    public function artist() {
        return $this->belongsToMany('App\Entities\Artist')->withPivot('active');
    }
}

Storing the members and quit_members works like a charm

$artist->members()->attach($artistData->members, array('active' => TRUE));
$artist->members()->attach($artistData->past_members, array('active' => FALSE));

To update the members I'd expected below code to work:

// One would expect this to work (sync m2m, for members set active=TRUE, for past_members set active=FALSE)
// first detach existing pivots which are not in the members-list, and attach (if necessary) the remaining members. set all "actives" to TRUE
$artist->members()->sync($artistData->members, array('active' => TRUE));
// keep the above set pivots, and attach (if necessary) the past_members, setting all "actives" to FALSE
$artist->members()->syncWithoutDetaching($artistData->past_members, array('active' => FALSE));

But somehow this code still detaches the existing entities. How can I deal with this. I don't want to add another pivot-table for this so that's why i use the active-column.

GitHub reference (line 45) https://github.com/PieterjanDeClippel/LyricDB/blob/master/app/Services/ArtistService.php