I'm looking to insert multiple column values into a table 'answers'. I'm inserting a question_id from questions table, which is being inserted successfully.
But it's not inserting the auth:user() id now, returning '0' in the table
answercontroller code:
<?php
namespace App\Http\Controllers;
use App\questions;
use Illuminate\Http\Request;
use Auth;
use App\Http\Requests;
class answerController extends Controller
{
public function store($question_id,Requests\answerAddRequest $request)
{
Auth::user()->questions()->findOrFail($question_id)->first()->answers()->create($request->all());
}
}
If I remove the questions()->findOrFail($question_id)->first()
part, it inserts the auth::id, but not with this, how can I fix it?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2eT6Owm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire