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
Tag: model
yii2 php set model attribute when clicking submit button
I have a view with a form in which I have users fill in attributes of the model. When submitting, I want the users to have the possibility to either publish the model or to save it as a draft. The difference basically only is a boolean “draft” that needs to be set in the database. As I am usually
cakephp 4.x query to get results from database
I came across a problem recently that I have to make a find(all) query in cakephp. Problem is I was unable to call model function to cakephp controller & add a command in function that would allow me to make a find(all) function in cakephp and retrieve all rows in a database that I was looking for. I would like
I have tried to run an existing laravel project. But during composer update I got this error:
Problem 1 Problem 2 Problem 3 Answer The error messages are quite clear. The packages you want to install require PHP 7, but you have PHP 8 installed. Your options are: Downgrade your PHP version Upgrade the package versions you depend on, if there are newer PHP 8 compatible versions
Zend Framework 3 : Unable to resolve service as a factory
I already saw many threads about my issue but none of the was able to fix it.. Indeed, I made a factory for my FournitureTable Model and the error returned is : Unable to resolve service “…
Adding custom method to Laravel model causes create() to ignore attributes
In Laravel 8, I have already had a working DocumentPdf resource – at least I was able to create the object using DocumentPdf::create($attributes). Now I want to create a custom method in the model, a one that will fill the document with $data and send it to browser. While it works for existing documents, adding the method broke create() in
Laravel: using database query in layouts page in Laravel
I have main layout page ,I want to use some database data in the navbar I did this to get data: where(‘user_id’,…
Userpermission pivot-function is only accessible via the Auth class
I have a simple Userpermission System consisting of 3 tables: users, permissions and the pivot table permission_user. This is the User model: and here is the Permission Model: Now when I try to get all the permissions of the currently logged in user with this: it works without problems. But when I try to get another Users Permissions like this:
Laravel class ‘UserRole’ not found
Hi i am trying to use a model for a test but i get Class ‘AppUserRole’ not found this is my controller where i am calling it
How to establish a one-to-many relationship to a model whose type is stored in db
I have a database that looks like this: Database Graphical Representation The dance_performer.perfomer_type field hosts values such at ‘AppDancer’, ‘AppCouple’ or ‘AppFormation’. How would you proceed to connect the dance_performer.perfomer_id to the different models? I am not sure how I am supposed to write the relationships in the different models. Should I create a AppPerformer model which would then direct