Skip to content

Call to a member function save() on null in Laravel test

I’m doing a Laravel course on Codecourse. So far I have a Category model: A factory: And a test However, when I run the test, I get: What gives? The course is a couple of years old so I think there’re a couple of differences between Laravel versions, but this seems a bit more fundamental. Answer Y…

Query a model using a relationship

I have a model called unit that has this relationship In the UserData model there is a column called user_id which I am trying to put in my condition in my query. I am trying to do a query like this but there is no user_id column in the Unit table, only though the users relationship Answer Ended up doing

How to restart loop with different variable in php/html

as you can see im doing a loop as below. There are 2 data set involved: How do i restart this same loop by using $transaction_list_completed as the variable in the foreach statement? Suggestion to copy the loop is not what im looking for (maybe if no other solution) as the html content for this Modal consists…

how to change array structure in laravel?

Hello everyone i get some problem when try learn php with laravel, there is the problem … i have an array structure like this : array:3 [▼ 0 => 16 1 => 19 2 => 15 ] how can u change …

How to pass error handling to a function in PHP?

I need to handle multiple types of error in many places in my PHP class in my Laravel project, and of course I don’t want to repeat error handling codes everywhere in my code. I have this code now: …