| 
									
										
										
										
											2016-01-08 16:02:15 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-20 12:27:31 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * User.php | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  |  * Copyright (c) 2018 thegrumpydictator@gmail.com | 
					
						
							| 
									
										
										
										
											2016-05-20 12:27:31 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-10-21 08:40:00 +02:00
										 |  |  |  * This file is part of Firefly III. | 
					
						
							| 
									
										
										
										
											2016-10-05 06:52:15 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-10-21 08:40:00 +02:00
										 |  |  |  * Firefly III is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Firefly III is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							| 
									
										
										
										
											2017-12-17 14:41:58 +01:00
										 |  |  |  * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2016-05-20 12:27:31 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-02-06 04:39:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | declare(strict_types=1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-08 16:02:15 +01:00
										 |  |  | namespace FireflyIII; | 
					
						
							| 
									
										
										
										
											2015-02-06 04:39:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-22 21:21:11 +01:00
										 |  |  | use FireflyIII\Events\RequestedNewPassword; | 
					
						
							| 
									
										
										
										
											2018-06-06 21:23:00 +02:00
										 |  |  | use FireflyIII\Models\Account; | 
					
						
							|  |  |  | use FireflyIII\Models\Attachment; | 
					
						
							|  |  |  | use FireflyIII\Models\AvailableBudget; | 
					
						
							|  |  |  | use FireflyIII\Models\Bill; | 
					
						
							|  |  |  | use FireflyIII\Models\Budget; | 
					
						
							|  |  |  | use FireflyIII\Models\Category; | 
					
						
							| 
									
										
										
										
											2017-04-13 20:47:59 +02:00
										 |  |  | use FireflyIII\Models\CurrencyExchangeRate; | 
					
						
							| 
									
										
										
										
											2018-06-06 21:23:00 +02:00
										 |  |  | use FireflyIII\Models\ExportJob; | 
					
						
							|  |  |  | use FireflyIII\Models\ImportJob; | 
					
						
							|  |  |  | use FireflyIII\Models\PiggyBank; | 
					
						
							|  |  |  | use FireflyIII\Models\Preference; | 
					
						
							| 
									
										
										
										
											2018-06-10 16:59:03 +02:00
										 |  |  | use FireflyIII\Models\Recurrence; | 
					
						
							| 
									
										
										
										
											2018-06-06 21:23:00 +02:00
										 |  |  | use FireflyIII\Models\Role; | 
					
						
							|  |  |  | use FireflyIII\Models\Rule; | 
					
						
							|  |  |  | use FireflyIII\Models\RuleGroup; | 
					
						
							|  |  |  | use FireflyIII\Models\Tag; | 
					
						
							|  |  |  | use FireflyIII\Models\Transaction; | 
					
						
							| 
									
										
										
										
											2019-01-28 20:00:40 +01:00
										 |  |  | use FireflyIII\Models\TransactionGroup; | 
					
						
							| 
									
										
										
										
											2018-06-06 21:23:00 +02:00
										 |  |  | use FireflyIII\Models\TransactionJournal; | 
					
						
							| 
									
										
										
										
											2016-02-12 05:49:53 +01:00
										 |  |  | use Illuminate\Database\Eloquent\Relations\BelongsToMany; | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  | use Illuminate\Database\Eloquent\Relations\HasMany; | 
					
						
							|  |  |  | use Illuminate\Database\Eloquent\Relations\HasManyThrough; | 
					
						
							| 
									
										
										
										
											2016-01-08 16:02:15 +01:00
										 |  |  | use Illuminate\Foundation\Auth\User as Authenticatable; | 
					
						
							| 
									
										
										
										
											2016-09-16 06:19:40 +02:00
										 |  |  | use Illuminate\Notifications\Notifiable; | 
					
						
							| 
									
										
										
										
											2018-07-22 18:50:27 +02:00
										 |  |  | use Illuminate\Support\Collection; | 
					
						
							| 
									
										
										
										
											2018-02-04 08:14:03 +01:00
										 |  |  | use Laravel\Passport\HasApiTokens; | 
					
						
							| 
									
										
										
										
											2016-11-22 21:21:11 +01:00
										 |  |  | use Request; | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-09 08:20:55 +01:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2017-11-15 12:25:49 +01:00
										 |  |  |  * Class User. | 
					
						
							| 
									
										
										
										
											2018-06-06 21:23:00 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-07-22 18:50:27 +02:00
										 |  |  |  * @property int        $id | 
					
						
							|  |  |  |  * @property string     $email | 
					
						
							|  |  |  |  * @property bool       $isAdmin used in admin user controller. | 
					
						
							|  |  |  |  * @property bool       $has2FA  used in admin user controller. | 
					
						
							|  |  |  |  * @property array      $prefs   used in admin user controller. | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:30 +02:00
										 |  |  |  * @property string     password | 
					
						
							| 
									
										
										
										
											2018-07-22 18:50:27 +02:00
										 |  |  |  * @property Collection roles | 
					
						
							|  |  |  |  * @property string     blocked_code | 
					
						
							|  |  |  |  * @property bool       blocked | 
					
						
							| 
									
										
										
										
											2016-01-09 08:20:55 +01:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-01-08 16:02:15 +01:00
										 |  |  | class User extends Authenticatable | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-04 08:14:03 +01:00
										 |  |  |     use Notifiable, HasApiTokens; | 
					
						
							| 
									
										
										
										
											2016-01-09 08:51:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 08:12:18 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The attributes that should be casted to native types. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected $casts | 
					
						
							|  |  |  |         = [ | 
					
						
							|  |  |  |             'created_at' => 'datetime', | 
					
						
							|  |  |  |             'updated_at' => 'datetime', | 
					
						
							|  |  |  |             'blocked'    => 'boolean', | 
					
						
							|  |  |  |         ]; | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The attributes that are mass assignable. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-07-26 15:51:07 +02:00
										 |  |  |     protected $fillable = ['email', 'password', 'blocked', 'blocked_code']; | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The attributes excluded from the model's JSON form. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected $hidden = ['password', 'remember_token']; | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The database table used by the model. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected $table = 'users'; | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @param string $value | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return User | 
					
						
							| 
									
										
										
										
											2018-04-02 14:17:11 +02:00
										 |  |  |      * @throws NotFoundHttpException | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-02-10 08:21:20 +01:00
										 |  |  |     public static function routeBinder(string $value): User | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-02-10 08:21:20 +01:00
										 |  |  |         if (auth()->check()) { | 
					
						
							| 
									
										
										
										
											2018-04-02 14:17:11 +02:00
										 |  |  |             $userId = (int)$value; | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  |             $user   = self::find($userId); | 
					
						
							| 
									
										
										
										
											2018-04-02 14:17:11 +02:00
										 |  |  |             if (null !== $user) { | 
					
						
							| 
									
										
										
										
											2018-01-10 07:51:47 +01:00
										 |  |  |                 return $user; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         throw new NotFoundHttpException; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to accounts. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function accounts(): HasMany | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Account::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:04:06 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-02-06 05:01:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-18 09:49:19 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to attachments | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-07-18 09:49:19 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function attachments(): HasMany | 
					
						
							| 
									
										
										
										
											2015-07-18 09:49:19 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Attachment::class); | 
					
						
							| 
									
										
										
										
											2015-07-18 09:49:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-30 13:47:23 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to available budgets | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-12-30 13:47:23 +01:00
										 |  |  |      * @return HasMany | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function availableBudgets(): HasMany | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(AvailableBudget::class); | 
					
						
							| 
									
										
										
										
											2016-12-30 13:47:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 08:58:01 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to bills. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-04-28 08:58:01 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function bills(): HasMany | 
					
						
							| 
									
										
										
										
											2015-04-28 08:58:01 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Bill::class); | 
					
						
							| 
									
										
										
										
											2015-04-28 08:58:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to budgets. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function budgets(): HasMany | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Budget::class); | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to categories | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function categories(): HasMany | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Category::class); | 
					
						
							| 
									
										
										
										
											2016-01-12 21:37:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 20:47:59 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to currency exchange rates | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2017-04-13 20:47:59 +02:00
										 |  |  |      * @return HasMany | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function currencyExchangeRates(): HasMany | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(CurrencyExchangeRate::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-04 17:14:59 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to export jobs | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2016-02-04 17:14:59 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-08-26 09:30:52 +02:00
										 |  |  |     public function exportJobs(): HasMany | 
					
						
							| 
									
										
										
										
											2016-02-04 17:14:59 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(ExportJob::class); | 
					
						
							| 
									
										
										
										
											2016-02-04 17:14:59 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-14 18:27:22 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Generates access token. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2017-09-14 18:27:22 +02:00
										 |  |  |      * @return string | 
					
						
							| 
									
										
										
										
											2019-02-16 08:05:48 +01:00
										 |  |  |      * @throws \Exception | 
					
						
							| 
									
										
										
										
											2017-09-14 18:27:22 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function generateAccessToken(): string | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $bytes = random_bytes(16); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-06 19:14:30 +02:00
										 |  |  |         return bin2hex($bytes); | 
					
						
							| 
									
										
										
										
											2017-09-14 18:27:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to import jobs. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |      * @return HasMany | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-08-26 09:30:52 +02:00
										 |  |  |     public function importJobs(): HasMany | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(ImportJob::class); | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to piggy banks. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasManyThrough | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function piggyBanks(): HasManyThrough | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasManyThrough(PiggyBank::class, Account::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to preferences. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function preferences(): HasMany | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Preference::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-10 16:59:03 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @codeCoverageIgnore | 
					
						
							|  |  |  |      * Link to recurring transactions. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return HasMany | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function recurrences(): HasMany | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Recurrence::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-12 05:49:53 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to roles. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-12 05:49:53 +01:00
										 |  |  |      * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function roles(): BelongsToMany | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->belongsToMany(Role::class); | 
					
						
							| 
									
										
										
										
											2016-02-12 05:49:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to rule groups. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function ruleGroups(): HasMany | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(RuleGroup::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to rules. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function rules(): HasMany | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Rule::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  |      * Send the password reset notification. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2017-11-15 12:25:49 +01:00
										 |  |  |      * @param string $token | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-08-04 17:30:06 +02:00
										 |  |  |     public function sendPasswordResetNotification($token): void | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-06-07 11:13:04 +02:00
										 |  |  |         $ipAddress = Request::ip(); | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-07 11:13:04 +02:00
										 |  |  |         event(new RequestedNewPassword($this, $token, $ipAddress)); | 
					
						
							| 
									
										
										
										
											2016-12-14 18:59:12 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-29 18:28:49 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to tags. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-03-29 18:28:49 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function tags(): HasMany | 
					
						
							| 
									
										
										
										
											2015-03-29 18:28:49 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(Tag::class); | 
					
						
							| 
									
										
										
										
											2015-03-29 18:28:49 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-28 20:00:40 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * @codeCoverageIgnore | 
					
						
							|  |  |  |      * Link to transaction groups. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return HasMany | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function transactionGroups(): HasMany | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(TransactionGroup::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to transaction journals. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasMany | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-08-26 09:30:52 +02:00
										 |  |  |     public function transactionJournals(): HasMany | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasMany(TransactionJournal::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2017-12-27 17:22:44 +01:00
										 |  |  |      * @codeCoverageIgnore | 
					
						
							| 
									
										
										
										
											2017-11-25 20:27:53 +01:00
										 |  |  |      * Link to transactions. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |      * @return HasManyThrough | 
					
						
							| 
									
										
										
										
											2015-02-11 07:35:10 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-06 10:11:06 +01:00
										 |  |  |     public function transactions(): HasManyThrough | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-04-28 06:23:13 +02:00
										 |  |  |         return $this->hasManyThrough(Transaction::class, TransactionJournal::class); | 
					
						
							| 
									
										
										
										
											2015-02-06 05:14:27 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-02-06 04:39:52 +01:00
										 |  |  | } |