pluck only category name and id from model in laravel code example
Example 1: pluck only category name and id from model in laravel
$categories = Category::all()->pluck('name', 'id');
Example 2: pluck only category name and id from model in laravel
<select name="category" class="form-control">
@foreach($categories as $category)
<option value="{{ $category->id }}" <?php if($hotel->category_id == $category->id) { echo "selected";}?>>{{ $category->name }}</option>
@endforeach
</select>