I have a question, I used the same blade template to create and insert. In my controller I created a variable ModificationMode on edit function and on the template I used isset()
method.
Controller
public function edit($id)
{
$ModificationMode = 0;
$DataPraticien = \App\Praticien::find($id);
return view('AjoutePraticien', compact('DataPraticien'))->with('ModificationMode', $ModificationMode);
}
View
@if(isset($ModificationMode))
<form method="post" action="{{route('prat.update', $DataPraticien ?? '')}}">
@csrf
@method('PATCH')
@else
<form action="{{route('prat.store')}}" method="post">
@endif
//stuff
//stuff
I make every variable as optional. Is that a good idea? Can this method bring me some issues? How about security?