I am newbie to PHP. I have admin panel (Backstage), created on Laravel. On panel shows list of bids (demos) from MySQL table (demos).
I have deleted all html from code below.
Here is code that shows every row from table in demo view:
@foreach($listDemos as $demo)
{{ $demo->id }}
{{ $demo->name }}
{{ $demo->email }}
{{ $demo->link }}
{{ $demo->created_at }}
@endforeach
Here is controller for demos
public function demo()
{
$listDemos = Demo::all();
return view('backstage.demos')->with('listDemos', $listDemos);
}
Here is route for demos:
Route::get('backstage/demos', 'BackstageController@demo');
I have another mysql table (demoStatus) with 2 columns
id and status
The question is how to store status (Decline) in different table (demoStatuswhere id = demo id from demo table and status = button value) by clicking button in demo view:
@foreach($listDemos as $demo)
{{ $demo->id }}
{{ $demo->name }}
{{ $demo->email }}
{{ $demo->link }}
{{ $demo->created_at }}
<form action="" method="post">
{{ csrf_field() }}
<button type="submit">Decline</button>
</form>
@endforeach
CSRF field stored at the head of every page
<meta name="csrf-token" content="{{ csrf_token() }}">
For demoStatus I have another model:
class DemoStatus extends Model
{
protected $table = 'demosStatus';
protected $fillable = 'status';
}
and model for demos:
class Demo extends Model
{
protected $table = 'demos';
}