Asked  7 Months ago    Answers:  5   Viewed   57 times

I've just installed a Laravel 5 project on MAMP and my pages are not finding the css files.

This is the link to my css in my app.blade.php file:

<link href="/css/app.css" rel="stylesheet">

And my .htaccess file has this line:

RewriteBase /laravel-site/laravel-5-app/public/

In the config folder my app.php file contains this:

'url' => 'http://localhost:8888/laravel-site/laravel-5-app/public/',

But when I open up this page: http://localhost:8888/laravel-site/laravel-5-app/public/auth/login and check the developer tools, it is looking for the css file at this location: http://localhost:8888/css/app.css

Just as a side note, if I go to this url: http://localhost:8888/laravel-site/laravel-5-app/public/ I get the correct welcome page.

 Answers

69

Use this to add assets like css, javascript, images.. into blade file.

FOR CSS,

<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" >

OR

<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet" type="text/css" >

FOR JS,

<script type="text/javascript" src="{{ asset('js/custom.js') }}"></script>

OR

 <script type="text/javascript" src="{{ URL::asset('js/custom.js') }}"></script>

FOR IMAGES,

{{ asset('img/photo.jpg'); }}

Here is the DOC

Alternatively, if you pulled the composer package illuminate/html which was come as default in laravel 4.2 then you can use like below, In laravel 5. you have to manually pull the package.

{{ HTML::style('css/style.css') }}

Here is an Example.

Wednesday, March 31, 2021
 
xrock
answered 7 Months ago
51

You are using join instead of left join

Try this

DB::table('A')
->leftjoin('B', 'A.program_id', '=', 'B.program_id')
->select('A.program_id')
->whereNull('B.program_id')
->where('A.student_id', '=', 5)
->get()->toArray();

It will produce a query like enter image description here

Saturday, August 7, 2021
 
Parfait
answered 3 Months ago
91

you need to provide the file contents in the second argument not file object, try this:

Storage::disk('local')->put($newFilename, file_get_contents($file));

Friday, August 13, 2021
 
Geekuna Matata
answered 3 Months ago
19

this is not problem on in vue.js or larvel. i moved my l Laravel API from Apache to nginx then working fine. i updated my middleware handler like this. then working fine on Apache server

  $origin = $request->server()['HTTP_ORIGIN'];

            if(in_array($origin, $url)){
                header('Access-Control-Allow-Origin: '. $origin);
                header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Csrf-Token'); 

            }
Tuesday, August 31, 2021
 
adizone
answered 2 Months ago
73

Yes, definitively, if each email layout is different, you should use Mailable

Mailable is the new way to send emails, easier than before. More customizable than Notifications.

Notification is very nice if you want to send a predefined layout in differents channel ( Mail, SMS, Slack, etc )

You can customize notifications layout, but having 1 layout by notification is going to get more difficult... it is just not the use case for notifications

Tuesday, September 7, 2021
 
Jerry Zhou
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :