Um simply maps the model to this table using Eloquent, as with any other Model> Table mapping.
Then you can simply call:
// Find the post $post = Post::find(1); // Check if post is question, assuming post_type is boolean/tiny int type if($post->post_type) { // Post is question if post_type is true } else { // Post is an anwser }
When you insert / add a new message, be sure to set post_type to ask him a question or answer.
This is all good and will work, but it is a poor hands-on programming experience. You really have to divide this into 3 tables: Post, Question, Answer and have a relationship between the three.
Sterling duchess
source share