Skip to content
Advertisement

Tag: laravel

How to test create model service?

I decided to create CreateClassroomService to separte logic in my controller method. I am trying to test this service as part of learning unit testing, but I don’t know how. I don’t know how to mock the classroom object to control what the method should return. Does this mean that creating this service was not a good idea because I

Combine categories tree

I have an array like that: In these arrays first level and second level are the same, only the last level is different. I want to combine them into one array. I want to receive result like that: Answer

How to group PHP arrays by key before sorting by another key?

I have an array that contains the key counted and placement which I am trying to group by before I sort. The array should be first sorted by counted and then, for each duplicate counted, should then sort by placement. My expected output here would be: I have tried to usort to achieve this: But this gives me an unexpected

Laravel Mutator Database Value with Variable variables

I have the following Laravel Eloquent Mutator When calling $object->used_working_time i get the value stored in the database as expected. When using Variable variables $object->{‘used_’.$name} with $name = ‘working_time’ the $db value is null. Is there a way to get the database attribute with the second way. I am using Laravel 8.74 and PHP 8.0. Answer Try to create a

Laravel how to properly pass data to href

sorry if the question is kind of newbie. I am new to php and laravel, still trying to learn through tutorial. I am trying to pass the ‘No’ in my database to the url, so that the url when I clicked on Daftar, it will show http://127.0.0.1:8000/search/{No} Webpage designed I did try to put it this way in my href

Advertisement