jpmurray /
laravel-countdown
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace jpmurray\LaravelCountdown\Traits; |
||||
| 4 | |||||
| 5 | use Carbon\Carbon; |
||||
| 6 | use Illuminate\Database\Eloquent\Model; |
||||
| 7 | use jpmurray\LaravelCountdown\Countdown; |
||||
| 8 | |||||
| 9 | trait CalculateTimeDiff |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Return elapsed time based in model attribite |
||||
| 13 | * |
||||
| 14 | * @param string $attribute |
||||
| 15 | * @return jpmurray\LaravelCountdown\Countdown $countdown |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 16 | */ |
||||
| 17 | public function elapsed($attribute) |
||||
| 18 | { |
||||
| 19 | $countdown = app('jpmurray.countdown'); |
||||
| 20 | $attribute = $this->{$attribute}; |
||||
| 21 | $now = Carbon::now(); |
||||
| 22 | |||||
| 23 | return $countdown->from($attribute) |
||||
|
0 ignored issues
–
show
The method
from() does not exist on Illuminate\Foundation\Application.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 24 | ->to($now)->get(); |
||||
| 25 | } |
||||
| 26 | |||||
| 27 | /** |
||||
| 28 | * Return until time based in model attribite |
||||
| 29 | * |
||||
| 30 | * @param string $attribute |
||||
| 31 | * @return jpmurray\LaravelCountdown\Countdown $countdown |
||||
| 32 | */ |
||||
| 33 | public function until($attribute) |
||||
| 34 | { |
||||
| 35 | $countdown = app('jpmurray.countdown'); |
||||
| 36 | $attribute = $this->{$attribute}; |
||||
| 37 | $now = Carbon::now(); |
||||
| 38 | |||||
| 39 | return $countdown->from($now) |
||||
| 40 | ->to($attribute)->get(); |
||||
| 41 | } |
||||
| 42 | } |
||||
| 43 |