I have 2 tables, a user
table and a working_hours
table. on the Add screen for working_hours
I want a drop down to allow a user to pick an ID from the users
table and when the submit button is pressed, it will store in my working_hours
table under the worker_id
column.
Controller:
public function store(Request $request)
{
$energy = new Work;
$energy->staff_id = $request->input('staff_id');
$energy->work_time = $request->input('work_time');
$energy->save();
return redirect('/vmaintenance')->with('success', 'data added');
}
Model:
class Work extends Model
{
public $timestamps = false;
protected $table = 'work_log';
protected $primaryKey = 'id';
protected $dates = ['date'];
protected $guarded = ['id'];
use HasFactory;
}
dropdown list:
<div>
<label>Select Staff</label>
<select name="staff_id" >
<option value="">--Select--</option>
</select>
</div>
I am very new to Laravel so I dont know what to put in that drop down.
Doe anyone know what I could do?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3m00t6V
via IFTTT
Aucun commentaire:
Enregistrer un commentaire