Ich weiß nicht, was dieser Fehler verursacht. Ich habe an meinen Codes nichts geändert. Aber wenn ich zu meiner Suchansicht gehe. Es gibt mir immer den undefinierten Eigenschaftsfehler zurück. Dieser Fehler verursacht, wenn ich versuchte, foreach alle meine Spalten in meinen Tabellendaten. Ich löse diesen Fehler nicht schon einmal. Weil es die $id
der ausgewählten Optionen nicht finden kann. Aber dieses Mal kann ich es nicht beheben.Was ist die Ursache Nicht definierte Eigenschaft: stdClass?
Fehler:
Undefined property: stdClass::$id (View: C:\Users\JohnFrancis\LaravelFrancis\resources\views\document\show.blade.php)
Ansicht
show.blade.php - Diese Ansicht wird alle Werte in meine Tabellen.
@section ('content')
<div class = "col-md-12">
<table class = "table">
<thead>
<tr>
<th>Title</th>
<th>Content</th>
<th>Category</th>
<th>Sender</th>
<th>Date Received</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($documentLists as $list)
<tr class = "info">
<td>{{ $list->title }}</td>
<td>{{ strip_tags(substr($list->content, 0, 50)) }} {{ strlen($list->content) > 50 ? "..." : '' }}</td>
<td>{{ $list->category_type }}</td>
<td>{{ $list->username }}</td>
<td>{{ date('M j, Y', strtotime($list->dateReceived)) }}</td>
<td>
<a href = "{{ route ('document.read', $list->id) }}"><button type = "submit" class = "btn btn-info">Read</button></a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
read.blade.php - Hier wird auf die ausgewählte aktuelle Ansicht umgeleitet.
<!--DOCUMENT CONTROLLER-->
<div class = "col-md-6">
<form class = "vertical">
<div class = "form-group">
<textarea id = "content">{{ $documentLists->content }}</textarea>
</div>
<div class = "form-group">
<button type = "submit" class = "btn btn-success">Approve</button>
</div>
</form>
</div>
-Controller
//SHOW
public function showDocuments()
{
$documentLists = DB::table('document_user')->select('documents.title', 'documents.content', 'categories.category_type', 'users.username', 'document_user.dateReceived')
//Table name //PK //FK
->join('users', 'users.id', '=', 'document_user.sender_id')
->join('documents', 'documents.id', '=', 'document_user.document_id')
->join('categories', 'categories.id', '=', 'documents.category_id')
->where('sender_id', '!=', Auth::id())
->where('user_id', '!=', Auth::id())->get();
//VIEW
return view ('document.show')->with('documentLists', $documentLists);
}
//READ
public function readDocuments($id)
{
//Find the document in the database and save as var.
$documentLists = Document::find($id);
return view ('document.read')->with('documentLists', $documentLists);
}
Routen
Route::get('/show',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.show',
'middleware' => 'auth',
]);
Route::get('/receive/documents/{id}',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.read',
'middleware' => 'auth',
]);
Haben Sie nicht verpasst haben bemerkt, dass ich die 'document_user.id' bin Auswahl statt 'document.id' mein Schlechter. – Francisunoxx