【发布时间】:2019-11-12 11:38:50
【问题描述】:
这是我用的
{{ $joburi->appends(\Request::except('page'))->render() }}
这是我的控制器
<?php
namespace App\Http\Controllers\Auth;
use Auth;
use App\Models\Joburi;
use App\Models\SkillsEmployee;
use App\Models\ProfileEmployee;
use App\Models\ProfileEmployer;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class JoburiController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
{
$joburi = Joburi::where('activ', 1)->limit(15)->get();
$skill = SkillsEmployee::all();
$employerimage = ProfileEmployer::where('uid', Auth::user()->id)->first();
$profileimage = ProfileEmployee::where('uid', Auth::user()->id)->first();
return view('joburiactive', compact('joburi', 'skill', 'employerimage', 'profileimage'));
}
}
在其他控制器上工作没有问题
有人知道我为什么会收到这个错误吗?
【问题讨论】:
-
你能显示你在另一个控制器中定义
$joburi的位置吗?appends是分页类的一部分,而您只是在这里获得 15 个对象的常规集合。 -
我发现了问题,我必须使用
$joburi = Joburi::where('activ', 1)->sortable()->paginate(5); -
因为在你的
$joburi变量赋值中使用的get方法返回一个Collection
标签: php laravel laravel-5 eloquent