Madhu Sudhan Subedi Madhu Sudhan Subedi - 1 year ago 114
CSS Question

How to link assets which are inside of module in Laravel?

I have problem to provide assets such as images, css, javascript when using module. Each module has each set of assets such as javascript, css, images inside of resources folder of that particular module and that i just compiled to inside of public folder of module. I have problem to provide to link to that assets.

I provide the link like this way

<link href="{{ asset('modules/robust/core/public/admin/css/app.css') }}" rel="stylesheet">

It shows this kind of result
enter image description here

I think i should define the custom path for the module assets But i do not know how to do that. Please help me.

Folder structure is like this.

enter image description here

Answer Source

As per our conversation in the comments, I suggest you divide your project in the following manner

  • app/Modules/

    • blog/
    • core/
    • etc.../
  • public/

    • blog/css
    • blog/js
    • blog/images
    • core/css
    • core/js
    • core/images
    • etc.../css
    • etc.../js
    • etc.../images

And then use commands like this in Controller


and in View, you can use this

{{ asset('blog/images/myimage.jpg') }}

If there are are more issue, please let me know by commenting below :)

Glad I could be of help :D

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download