How can I set the id as a primary key manual? In the other hand, I don't want to use Auto Increment for this primary key.
1- My database
MyTable
id - int --> auto increment <-- I don't want to use it.
data - text
I want to insert to this table using Form and I want to set the value of id as the value as I want.
In mysql remove AUTO_INCREMENT from id column
In form use $form->text('id');
I have followed exactly steps but when go to create page the Primary key field do not show up.
@mfvodka107 Try following code
protected function form($creating = false)
{
....
if ($creating) {
$form->text('gid', 'ID');
}
$form->saving(function ($form) {
$form->input('id', request()->get('gid'));
});
}
And in create method of controller
public function create(Content $content)
{
return $content
->header('Header')
->description('description')
->body($this->form(true));
}
Most helpful comment
@mfvodka107 Try following code
And in create method of controller