0

I have a question about routing. I make my menu as a database. Then when I click "job company" on my website, it gave me error Route [company.insert_logo] not defined. on my blade. I keep changing between my database and my blade but it doesn't work. I want to submit a form with image to the database. Below I attach my code

my company.blade.php

<form method="post" action="{{ route('company.insert_logo') }}"  enctype="multipart/form-data">
                                @csrf
                                <div class="intro-y box p-5">
                                    <div class="mt-3">
                                        <label>Company</label>
                                        <div class="mt-2">
                                            <label class="input w-full border mt-2" align="right">Select Company Logo</label>
                                            <div class="col-md-8">
                                                <input type="file" name="company_logo" />
                                            </div>
                                          
                                        </div>
                                    </div>

                                    <div class="mt-3">
                                        <label>Position Name</label>
                                        <input type="text" class="input w-full border mt-2 form-control" name="company_name" placeholder="Company Name">
                                    </div>
                                    <div class="text-right mt-5">
                                        <button type="button" class="button w-24 border dark:border-dark-5 text-gray-700 dark:text-gray-300 mr-1">Cancel</button>
                                        <button type="submit" class="button w-24 bg-theme-1 text-white" name="store_company" >Save</button>
                                    </div>

                                    {{-- <input type="submit" name="store_image" class="btn btn-primary" value="Save" /> --}}

                                </div>

                            </form>
                        
                        </div>

web.php

Route::resource('company', 'CompanyController');

I believe that I might write something wrong for my web.php but I am really not sure where.

Lets say I'm not using resource

web.php

Route::get('store_company', 'CompanyController@index');
Route::post('store_company/insert_logo', 'CompanyController@insert_logo');
Route::get('store_company/fetch_logo/{id}', 'StoreImageController@fetch_logo');

and I change my blade using URL instead of routing to

 <form method="post" action="{{ url('store_company/insert_logo') }}"  enctype="multipart/form-data">

I am still getting the same error which is routing for my company.index(inside my database menu) is undefined

6
  • 1
    Actions Handled By Resource Controller has a list of routes/actions when using resource routes. 'company.insert_logo' is not one of them, you'd need to create a separate Named Route for that
    – user8034901
    Commented May 16, 2021 at 18:52
  • If I change this part <form method="post" action="{{ route('company.insert_logo') }}" enctype="multipart/form-data"> I still not getting it right. I change it into company.store
    – kins
    Commented May 16, 2021 at 19:06
  • Tip: A screenshot of your database schema is almost always useless. When applicable include the cleaned up output of SHOW CREATE TABLE. Use \G in the mysql> shell to keep it tidy.
    – tadman
    Commented May 16, 2021 at 19:06
  • @tadman sorry but I am not getting what you mean
    – kins
    Commented May 16, 2021 at 19:08
  • That screenshot shows almost zero information and takes up a lot of space. The SQL version of same actually helps. It contains a lot of information.
    – tadman
    Commented May 16, 2021 at 19:09

1 Answer 1

0

use name for your route

for example

Route::post('store_company/insert_logo', 'CompanyController@insert_logo')->name('INSERT_LOGO');

{{ route('INSERT_LOGO') }}
6
  • I am still getting the same error Route [company.index] not defined. I believe this is something to do with my menu inside my database but I don't know how to fix it
    – kins
    Commented May 16, 2021 at 19:16
  • @kins You still have the resource route, right? Route::resource('company', 'CompanyController'); In addition to that, add the named route as mentioned in my comment
    – user8034901
    Commented May 16, 2021 at 19:20
  • @brombeer yes but I am getting an error saying Undefined variable: menu (View: C:\Usersxampp\htdocs\company\resources\views\layout\sidenav.blade.php) I update my side-nave.blade.php on my question
    – kins
    Commented May 16, 2021 at 19:23
  • @kins That sounds like it's not related to the question, a completely new error and new blade file. Is your question regarding the route resolved?
    – user8034901
    Commented May 16, 2021 at 19:25
  • @brombeer hmm no it is not. It still getting error. Because whenever I click on company button on my side-nav menu, it showing the undefined variable:menu so I cannot view my company.blade.php
    – kins
    Commented May 16, 2021 at 19:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.