There are many ways you could achieve it
One example would be, pass an 'action' value in to your views
Create
return view('stuff.create_or_edit', ['action' => 'create']);
Edit
return view('stuff.create_or_edit', ['action' => 'edit']);
in your view, store the action in your form
<form method="POST" action="{{ route('stuff.store') }}>
<input type="hidden" name="action" value="{{ $action }}">
@if($action == 'create')
<button type="submit" class="btn">Create Stuff</button>
@else
<button type="submit" class="btn">Update Stuff</button>
@endif
</form>
and in your controller store method
// Rules which apply to both
$rules = [
'name' => 'required'
];
// Rules which apply to create
if (request('action') == 'create' {
$rules['create_field_to_validate'] = 'required';
}
$this->validate(request(), $rules);
Or if that's too messy for your controller, create a request class
php artisan make:request
and bundle up that logic in the request class as per https://laravel.com/docs/5.4/validation#form-request-validation
Another way is to have seperate create and view forms and include the main form within. You could even have each type go to a different action route and keep your validation for each type contain in their own controller methods.
In your controller method for create, return your create view
return view('stuff.create');
In your create view, include the guts of your form and pass in an action and possibly what to have on your submit button
<form method="POST" action="{{ route('stuff.create_store') }}">
@include('stuff.partials._form', ['action' => 'create', 'buttonText' => 'Create Stuff'])
</form>
In your controller method for edit, return your edit view passing in your model data
return view('stuff.edit')->with(compact('stuff'));
the edit view
<form method="POST" action="{{ route('stuff.edit_store') }}">
@include('stuff.partials._form', ['action' => 'edit', 'buttonText' => 'Update Stuff'])
</form>
You can do different things in your _form view you include in depending on the action
@if ($action == 'edit')
<input type="hidden" name="id" value="{{ $stuff->id }}">
@endif
<button type="submit" class="btn">{{ $buttonText }}</button>
There's no right or wrong way. Comes down to what feels right for what you're working on and how it feels to you.
You may find you'll do it one way now, and a compete different way in 6 months after you have some mileage under your belt. :)