Here I überprüfen müssen tut Auktion für Artikel in meiner app Live ist so schreibe ich Artikel Modell:Laravel 5.1 - vergleichen Carbon-Daten
public function scopeCloseauction($query){
$query->where(Carbon::parse('to')->subDays('auction_end'),'>',Carbon::now());
}
und sehen Ich habe:
@if ($article->Closeauction())
<td>
auction is live
</td>
@else
<td>
auction is closed
</td>
@endif
aber ich habe ein Problem becouse ich eine Fehlermeldung anzeigt:
UPDATE: ich versuche auch: in Modellfunktion hinzuzufügen:
public function isLive($to,$auction_end) {
$first = Carbon::create($to).subDays($auction_end);
$second = Carbon::now();
return ($first->lte($second));
}
und im Blick:
@if ($article->isLive($article->to,$article->auction_end))
<td>
live
</td>
@else
<td>
closed
</td>
@endif
aber geben Sie mir jetzt diesen Fehler:
ErrorException in Carbon.php line 425: Unexpected data found. Unexpected data found. Unexpected data found. Trailing data (View: C:\wamp\www\project\resources\views\articles\index.blade.php)
ich auch versuchen: public function scopeCloseauction ($ query) { $ query-> where (('zu'). SubDays ('auction_end'), '>', Kohlenstoff :: now()); } aber sagen: Aufruf zu undefinierter Funktion App \ subDays() – Andrew