laravel create model view code example
Example 1: laravel view-model
<input type="text" value="{{ $post->title }}" />
<input type="text" value="{{ $post->body }}" />
<select>
@foreach ($categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
</select>
<a href="{{ $indexUrl }}">Back</a>
Example 2: laravel view-model
class PostsController
{
public function update(Request $request, Post $post)
{
return (new PostViewModel($post))->view('post.form');
}
}