mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Cleaned up.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,6 @@ | ||||
| composer.phar | ||||
| Thumbs.db | ||||
| .idea/ | ||||
| .DS_Store | ||||
| tests/_output/* | ||||
| _ide_helper.php | ||||
| /build/logs/clover.xml | ||||
|   | ||||
| @@ -45,7 +45,6 @@ class PiggyBank extends Model | ||||
|             return $rep; | ||||
|         } else { | ||||
|             Log::error('Tried to work with a piggy bank with a repeats=1 value! (id is '.$this->id.')'); | ||||
|             //App::abort(500); | ||||
|         } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| <?php namespace FireflyIII\Models; | ||||
|  | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
| use Illuminate\Database\Eloquent\Builder as EloquentBuilder; | ||||
| use Carbon\Carbon; | ||||
| use Illuminate\Database\Eloquent\Builder as EloquentBuilder; | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
|  | ||||
| /** | ||||
|  * Class PiggyBankRepetition | ||||
|  * | ||||
| @@ -27,27 +28,6 @@ class PiggyBankRepetition extends Model | ||||
|         return $this->belongsTo('FireflyIII\Models\PiggyBank'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param EloquentBuilder $query | ||||
|      * @param Carbon          $date | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function scopeRelevantOnDate(EloquentBuilder $query, Carbon $date) | ||||
|     { | ||||
|         return $query->where( | ||||
|             function($q) use ($date) { | ||||
|                 $q->where('startdate', '<=', $date->format('Y-m-d 00:00:00')); | ||||
|                 $q->orWhereNull('startdate'); | ||||
|             }) | ||||
|  | ||||
|             ->where(function($q) use ($date) { | ||||
|  | ||||
|                 $q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00')); | ||||
|                 $q->orWhereNull('targetdate'); | ||||
|             }); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param EloquentBuilder $query | ||||
|      * @param Carbon          $start | ||||
| @@ -57,7 +37,30 @@ class PiggyBankRepetition extends Model | ||||
|      */ | ||||
|     public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target) | ||||
|     { | ||||
|         return $query->where('startdate',$start->format('Y-m-d'))->where('targetdate',$target->format('Y-m-d')); | ||||
|         return $query->where('startdate', $start->format('Y-m-d'))->where('targetdate', $target->format('Y-m-d')); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param EloquentBuilder $query | ||||
|      * @param Carbon          $date | ||||
|      * | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function scopeRelevantOnDate(EloquentBuilder $query, Carbon $date) | ||||
|     { | ||||
|         return $query->where( | ||||
|             function (EloquentBuilder $q) use ($date) { | ||||
|                 $q->where('startdate', '<=', $date->format('Y-m-d 00:00:00')); | ||||
|                 $q->orWhereNull('startdate'); | ||||
|             } | ||||
|         ) | ||||
|                      ->where( | ||||
|                          function (EloquentBuilder $q) use ($date) { | ||||
|  | ||||
|                              $q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00')); | ||||
|                              $q->orWhereNull('targetdate'); | ||||
|                          } | ||||
|                      ); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user