Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

287
Visualizações
Change the asset helper url in Laravel

The asset() or URL::asset() will point to http://my-url/public/ in default.

Is there any way to change the url of asset() to http://my-url/public/assets/ ?

I have many asset files which I should use in my blade templates and I don't want to write assets any time.

I mean use asset('js/script.js') instead of asset('assets/js/scripts.js') in my blade templates.

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Overriding default asset() is a bad idea but you can do it by defining your own helper implementation:

function asset($path, $secure = null)
{
    return app('url')->asset($path.'/asset', $secure);
}

But it's a better way to define your own helper like customAsset().

about 4 years ago · Santiago Trujillo Relatório

0

I was also in a situation to use the S3 as a file provider. After searching the Laravel document, I found the following solution. You can configure the asset URL host by setting the ASSET_URL variable in your .env file.

https://laravel.com/docs/7.x/helpers#method-asset

about 4 years ago · Santiago Trujillo Relatório

0

By default, there isn't any configuration for that. You can create your custom function like this:

function my_asset($path, $secure = null){
    return asset('/assets/' . trim($path, '/'), $secure);
}
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda