Answers for "pluck only category name and id from model in laravel"

PHP
0

pluck only category name and id from model in laravel

$categories = Category::all()->pluck('name', 'id');
Posted by: Guest on April-25-2021
0

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>
Posted by: Guest on April-25-2021

Code answers related to "pluck only category name and id from model in laravel"

Browse Popular Code Answers by Language