Skip to main content
Laravel

Laravel User Model

By December 10, 2021No Comments

A boilerplate for the User model, expected to be reused in future projects.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*------------------------------------------------
        Getters and Setters Access Manipulation
    --------------------------------------------------*/


    /**
     * Trim email, otherwise it could cause issues with swiftmailer, as it doesn't like spaces.
     * @source https://github.com/swiftmailer/swiftmailer/issues/382#issuecomment-124560149
     *
     * lowercase should of course be there
     *
     * @param $value
     * @return void
     */

    public function setEmailAttribute($value)
    {

        $this->attributes['email'] = strtolower(trim($value));
    }