I have the following database design
Using this, I can create Documents of different types, everything tied together by the documentId.
In my Document Controllers create function, I have the following which should find the Document relating to the view, and pass it to the edit page
$document = Document::find($result->documentId);
dd($document);
return View::make($documentLink.'Doc.edit', compact('project', 'document'));
The dd outputs the following
Document {#238 ▼
#table: "documents"
#guarded: []
#connection: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:5 [▼
"id" => 3
"projectId" => 1
"deleted_at" => null
"created_at" => "2016-01-06 13:29:15"
"updated_at" => "2016-01-06 13:29:15"
]
#original: array:5 [▶]
#relations: []
#hidden: []
#visible: []
#appends: []
#fillable: []
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
Now obviously, this does not have the Documents Data because this is in the document_data table.
So, can is there a way I can either pass the view the data for a particular document, or access the data within the view via the document Object?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire