irankhosravi
10 months ago
26
10
Laravel

Undefined variable: category

Posted 10 months ago by irankhosravi

I use below link

https://laracasts.com/discuss/channels/laravel/how-to-save-category-in-laravel-57-with-vuejs

I'm working on a Laravel (v 5.7) project and i did the form to manage categories. Currently, i can create a new category and i would be able to delete.

I created the view (with blade) to delete the categories :

<form action="{{ route('categories.destroy', ['id' => $category->id]) }}" method="post">
    {{ method_field('delete') }}
    @csrf
    <div class="form-group">
        <label for="categories">Category:</label>
        <select name="{{ category->id }}">{{ category->name }}</select>
    </div>
    <div class="form-group">
        <button type="button" class="btn btn-danger">Delete</button>
    </div>
</form>

And in the routing file web.php, I wrote :

Route::group(['namespace' => 'Admin', 'prefix' => 'admin'],function (){
    $this->resource('categories', 'CategoryController');
});

Now I want to select a category from the list and delete it, How to work with vue.js

But I get this error

Undefined variable: category (View: C:\xampp\htdocs\project\divar\resources\views\Admin\categories\index.blade.php)

Please sign in or create an account to participate in this conversation.