I have two countries and states tables between them hasMany belongsTo relation. I want to fill table states using seeder but it gives me this error: ‘country_id’ doesn’t have a default value StatesTableSeeder.php Answer You never defined a country in which you want to add a state. There are …
Tag: laravel
Column not found 1054 error when defining laravel relationship
I have two tables: Order and Order_details. Between these two tables, there is a one-to-many relationship. Order fields are: id_order invoice customer_id user_id total Order_details fields: order_detail_id order_id product_id qty price order_id is a foreign key which references to id_order on orders table Ord…
Accessing the contents of .env via the env Facade
In my Laravel 7.x application, I added some basic configuration to my .env file, eg: MY_SECRET_KEY=foo In my controller, I am attempting to read in the value via the following: Log::debug(“ENV[…
Function to check user birth date is 18 years or upper not always work correctly
I am beginner webdeveloper. I use in my project Laravel 5.8. I have this this code: It’s work fine. But I have problem with date ex 2045-12-12. This function is not working. With year: 2015-12-12 – it’s okey. How can I repair it? Answer I would write your function to return true or false dep…
Calculating variable using attribute laravel
I have a simple code where I output the new age of a person. If a person is aged 17, it should output 18. But I’m calculating this on blade (which I think is bad). And I’m trying attribute to handle this, but since I’m very new to Laravel, I don’t know how to handle it. Please help me&…
LARAVEL – How to change Auth::route() paths to custom address
I am working on laravel7 Project, I want to change default Auth::route() route paths I have login page and I want to change it to something like: /random/random2/random3/login but laravel auth comes with “/login”. how can I edit it? Answer If you just want to prefix them, you can wrap it in a rout…
Can’t access the Auth::user() from a custom route file ? Laravel 7
For a purpose i decided to create a separate routing file for the admin and separating its logic from the web.php but instead i am facing this issue : ps: the admin.php is registered in the RouteServiceProvider Answer Add web middleware
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘0430142821’ for key ‘users_melli_unique’
I know this question asked before but i want to know how can i stop to showing this error and instead of this i want to show custom error message to user in blade. This is user migration : UPDATE: This is my insert function : This error happens when i have a melli in my database like 1234567890 and
Laravel Dusk: FacebookWebDriverExceptionUnknownErrorException: unknown error: net::ERR_CONNECTION_REFUSED
Running php artisan dusk get the error: Versions: OS: Windows 10 v1903 build 18362.1016 Chrome: 85.0.4183.83 Laravel: v6.18.37 Dusk: v5.11.0 Phpunit: v8.5.8 Tried: Disable firewall Set test website to use localhost (was myapp.local) Can access all pages using Chrome browser Check that vendor/laravel/dusk/bin/…
how to customize Auth::routes in laravel
I hope you are the best. I’m trying to create a multi-language feature in my Laravel app. but I don’t know how to insert Auth::routes in my web routes file to support my multi-language. this code …