G
G
GaserV2016-04-02 14:38:01
Laravel
GaserV, 2016-04-02 14:38:01

How to make one page for adding\editing work?

Hi all! Tell me please. I am writing an admin. I want to make one page for adding/editing work. How to implement? It's just that in fact it will be the same page, only on the edit page the data from the database will already be displayed in the fields, and on the add page the same fields, only empty. So. How to do it better? Share your ideas, I will be grateful!
For example, I will have a general /new-work page to add. And for editing, you will need to follow the link by adding an id, such as /new-work-355. So, you need to somehow check something, if the URL = the second option, then display data from the database, but if the first one, then do not display anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-04-02
@wielski

LARAVEL

In the form method of the WorksController controller, we accept the $id variable , and if it exists, we pass the view variable with the field data from the database.
In blade we output something like this:
{{ old('name') ? old('name') : (isset($edit->name) ? $edit->name : '') }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question