Use of undefined constant laravel
Use of undefined constant laravel
Through many examples, we will learn how to resolve the "Use of undefined constant laravel".
You got this error message, Use of undefined constant if the string missing quotes and the variable missing the dollar symbol. Without quotes or dollar symbol PHP treats it as a constant which does not exist then it gives an error message.-
Solved undefined constant error in laravel view using single quotes
//Code with errorĀ //misssing single quotes {{ $post->created_at->format(Y-m-d) }} //Code with solution // add single quotes while passing value to format method {{ $post->created_at->format('Y-m-d') }}
You have to pass a value with a single quote in the method. This error occurs because laravel treats it as a constant name because you did not pass the value to the method with single or double quotes.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Count all and get 10 records after where condition in laravel
- Extra Filter Query on Relationships in Laravel
- Automatically remove records using Prunable trait in Laravel
- How to get selected categories on edit record with Select2
- Get current month records in laravel 7/8
- Display message with session flash using bootstrap alert class in laravel
- How to change default timestamp fields name in Laravel
- If no route matched route::fallback in laravel
- How to create project_user pivot table in laravel
- How to check email is valid or not in Laravel
- Get products with number of orders in Laravel
- Pagination in laravel
- Laravel onclick function not working
- Laravel specific table Migration
- How to pass data to route in laravel?
- How to call model in blade laravel
- Get today records in Laravel
- Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection refused)"
- InRandomOrder() method with example in laravel
- Get last record from table in laravel
- Best Practices for Error Handling in Production Server Code (example code)
- After image selected get validation error in laravel
- Page loader in laravel
- Laravel 5.4 save data to database
- Session Doesn't Work on Redirect