0
ラズベリーパイの2つのローカルともう1つのローカルのインストールがあります。私はgitリポジトリを使って同期しています。ブレードブレーキ表示のモデル機能を呼び出す - Laravel
私は先生と学校の間に1対1の関係があります。
これは私の先生のモデルである:
教師 - モデル
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Teacher extends Authenticatable
{
use Notifiable;
protected $guard = 'teacher';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function students() {
return $this->hasMany('App\Student');
}
public function school() {
return $this->belongsTo('App\School');
}
}
そして、これは、ウェブ版ブレイク
一部である教師 - ビュー
@foreach ($teachers as $teacher)
<tr>
<td>{{ $teacher->id }}</td>
<td>{{ $teacher->name }}</td>
<td>{{ $teacher->school->name }}</td>
<td>{{ $teacher->email }}</td>
<td><a class="btn btn-small btn-info" href="teachers/{{ $teacher->id }}">View</a></td>
</tr>
@endforeach
TeacherController
<?php
namespace App\Http\Controllers\Admin;
use App\Teacher;
use App\School;
use Illuminate\Http\Request;
use App\Http\Requests\StoreTeacher;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Validation\Validator;
class TeacherController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth:admin', ['except' => 'logout']);
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$teachers = Teacher::all();
$schools = School::all();
return view('admin.teachers.index')
->with('teachers', $teachers)
->with('schools', $schools);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(StoreTeacher $request)
{
$teacher = new Teacher;
$teacher->name = $request->input('name');
$teacher->email = $request->input('email');
$teacher->password = $request->input('password');
$teacher->school_id = $request->input('school_id');
$teacher->save();
return redirect('admin/teachers')->with('status', 'New teacher created!');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$teacher = Teacher::findOrFail($id);
return view('admin.teachers.show')->with('teacher', $teacher);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$teacher = Teacher::findOrFail($id);
return view('admin.teachers.edit')->with('teacher', $teacher);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$teacher = Teacher::findOrFail($id);
$teacher->delete();
return redirect('/admin/teachers')->with('status', 'Teacher deleted!');
}
}
が、これは誤りです:
in 5bdd62e78cd0ce07d649d6a0703baeeac6c5e20e.php line 21
at CompilerEngine->handleViewException(object(ErrorException), 1) in PhpEngine.php line 44
at PhpEngine->evaluatePath('/var/www/The-Film-Corner/storage/framework/views/5bdd62e78cd0ce07d649d6a0703baeeac6c5e20e.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(Illuminate\Support\ViewErrorBag), 'teachers' => object(Collection), 'schools' => object(Collection))) in CompilerEngine.php line 59
at CompilerEngine->get('/var/www/The-Film-Corner/resources/views/admin/teachers/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'teachers' => object(Collection), 'schools' => object(Collection))) in View.php line 137
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 38
at Response->setContent(object(View)) in Response.php line 225
at Response->__construct(object(View)) in Router.php line 602
at Router->prepareResponse(object(Request), object(View)) in Router.php line 560
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 43
at Authenticate->handle(object(Request), object(Closure), 'admin') in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
最も不可解な部分は、アプリのすべてのローカルバージョンで正常に動作していることです。あなたのための
おかげで
レンダリングされたビューで見つけやすくなることがあります。あなたのストレージフォルダ内で5bdd62e78cd0ce07d649d6a0703baeeac6c5e20e.php(またはそれが参照するファイル)を探し、そこで21行目を探します。 – aynber
コントローラコードを提供できますか? – nextt1
@aynberそれほど簡単ではありません。行21{{$ teacher-> school-> name}} –