I have retrieved data from database and populate form select. But value is not inserting in database.
Here is my controller:
public function store(Request $request ){ $data['Team_Lead_ID] = $request['Team_Lead_ID']; teams::create($data); return a redirect()->back(); }
And here is my blade;
`@foreach ($team_lead as $teaml)
<option value = "{{$teaml->Id}}"> {{$teaml->name) </option>`But this is not inserting data to teams. Why is that? I am new to laravel and just started making web applications.
Note-: $team_lead is the variable containing Id and name retrieved from another database. And it is feeding data to the form alright
Do you have a column name as I'd
stored in the database table? If yes, then update it to something like id
as you must only use _
as special character while defining your database column names otherwise it will create problems while creating and retrieving data.
The table where I am retrieving data from has a column id. I populate select option value with id and I am trying to insert into another table column Team_Lead_ID.
My code is retrieving data alright. The problem is inserting the retrieved id into column Team_Lead_ID in the new table.
Can you share your code so that it will be easy to understand and help you in resolving your problem?
I have solved it. I didn't know to include it in $fillable in Model. I thought it is not necessary as it is not a direct user input. I added it to $flilable in model and it works. Thanks
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community