php - Laravel 5.2 balde/css stops working when routing sub url through controller

I can't figure it out what could cause this issue, but i'am pretty sure it simple. I am extending main view main.blade.php (located in views folder). This includes css from partials folder.

I have two pages: Enquire, Approved enquire. (both located in views/trader/ folder.) only difference is routing, one would have /enquires the other would have /enquires/approved.

Blade/Css working if on main route: Route::get('/enquires','Trader\PagesController@getEnquires');
Blade/Css does not work when using suburl: Route::get('/enquires/approved','Trader\PagesController@getApproved');

Please refer to this image: routing display error

If you require any other information please let me know, Tahnks in advance, Dan

2 Answers

  1. Aaron- Reply

    2019-11-16

    It seems the problem is in how you're creating links to assets (images, CSS and JS files). To make it work, use Laravel asset() helper:

    <link rel="stylesheet" href="{{ asset('css/theme.css' }}">
    

    Which will create full path to an asset.

    Also, you must keep all assets inside public directory of your project, for example: /laravel_project/public/css/theme.css

  2. Abel- Reply

    2019-11-16

    <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">   
    
        <title>@yield('title')</title>  
    
        <meta name="keywords" content="HTML5 Template" />
        <meta name="description" content="Trusted Workers - Find local tradesmen">
    
        <!-- Favicon -->
        <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
        <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
    
        <!-- Mobile Metas -->
        <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    
        <!-- Web Fonts  -->
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light" rel="stylesheet" type="text/css">
    
            <!-- Vendor CSS -->
        <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.css">
        <link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css">
        <link rel="stylesheet" href="vendor/owl.carousel/assets/owl.carousel.min.css">
        <link rel="stylesheet" href="vendor/owl.carousel/assets/owl.theme.default.min.css">
        <link rel="stylesheet" href="vendor/magnific-popup/magnific-popup.css">
    
    
        <!-- Theme CSS -->
        <link rel="stylesheet" href="css/theme.css">
        <link rel="stylesheet" href="css/theme-elements.css">
        <link rel="stylesheet" href="css/theme-blog.css">
        <link rel="stylesheet" href="css/theme-shop.css">
        <link rel="stylesheet" href="css/theme-animate.css">
    
        <!-- Current Page CSS -->
        <link rel="stylesheet" href="vendor/rs-plugin/css/settings.css" media="screen">
        <link rel="stylesheet" href="vendor/rs-plugin/css/layers.css" media="screen">
        <link rel="stylesheet" href="vendor/rs-plugin/css/navigation.css" media="screen">
        <link rel="stylesheet" href="vendor/circle-flip-slideshow/css/component.css" media="screen">
    
        <!-- Skin CSS -->
        <link rel="stylesheet" href="css/skins/default.css">
    
        <!-- Theme Custom CSS -->
        <link rel="stylesheet" href="css/custom.css">
    
        <!-- Head Libs -->
        <script src="vendor/modernizr/modernizr.js"></script>
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>