laravel - App 的返回值必须是实例 Laravel 错误
问题描述
我有文件上传器,当其到期日期大于或等于今天的日期时,我想显示已过期而不是下载链接
它是我的模型:
class Panelfile extends Model
{
protected $guarded = [];
public function
getLinkAttribute()
{
return
$this->isExpired() ? null :
$this->file;
}
public function
isExpired() : boolean
{
return Carbon::now()->gte($this->expiration);
}
protected $appends = ["link"];
protected $casts = [
'expiration' =>
'datatime:Y-m-d H:i:s',
];
}
及其我的观点:
@foreach($filepanels as $filepanel)
<div class="widget-download-file d-flex align-items-center justify-content-between mb-4">
<div class="d-flex align-items-center mr-3">
<div class="download-file-icon mr-3" style="background-color: {{$filepanel->color}};">
<img src="{{$filepanel->png}}" alt="">
</div>
<div class="user-text-table">
<h6 class="d-inline-block font-15 mb-0">{{$filepanel->title}}</h6>
<p class="mb-0">{{$filepanel->description}}</p>
</div>
</div>
@if ($filepanel->link === null)
<p>Expired</p>
@else
<a href="{{$filepanel->file}}" class="download-link badge badge-primary badge-pill">دانلود</a>
@endif
</div>
@endforeach
这是我的错误:
Return value of App\Panelfile::isExpired() must be an instance of phpDocumentor\Reflection\Types\Boolean, bool returned (View: C:\wamp64\www\site\resources\views\back\filesview\view.blade.php)
我该如何解决?
解决方案
推荐阅读
- mysql - 有条件地计算一行中的一列是多个值之一的次数?
- r - 如何使用 OR 在正则表达式中的字符串操作的多个匹配项之间进行选择
- excel - 如何将数据附加到一组数据VBA的底部
- elasticsearch - error_class=Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure error="could not push log to Elasticsearch cluster
- streaming - 一个有效的 Ogg/Opus 流可以包含重复的 Opus 标头吗?
- python - 如何使用 Pathlib 在 Django/Faker 中配置项目的设置?
- java - Java Swing-面板未出现在框架中
- python - Pandas Excel groupby/count
- github - 从我的桌面 GitHub,我如何重定向提交并推送到从原始主服务器克隆的新远程存储库?
- c# - WPF 进度条未正确更新