Skip to content

Tag: laravel

Explain Eloquent morphMany parameters

I am new to laravel, can someone explain to me the parameters of morphMany: Answer The MorphMany relationship has the following function signature: Where: $related (required): refers to the related model. e.g: User::class. $name (required): the name of the polymorphic relation, like commentable. $type (option…

How can I show subcategories in categories?

Here’s the code: I will like to display parent category and its children under it. Something like this: Category Sub 1 Sub 2 Category – Sub 1 – Sub 2 I want to show data like see demo Database Structure. Both categories and subcategories are in same table. Database Answer Try this: Output:

watch database and wait for changes in laravel

i have a messaging system app and every message has some status in it with 3 types of done , in progress,not started so when i send a message to user B its not started for example so when user B receive the message he changes the status to in progress here i want to send a notification to the

Laravel UUID’s and their uniqueness?

I have two tables, one for lists and another that stores a history of lists that were created. These lists are very temporary and they can be deleted by numerous methods so I add a reason field on the history for that. Now both have a uuid field and I can generate an actual string to store with Laravel’…

Carbon parse to ISO8601

I am trying to get the current time and format it like: “2018-09-26T21:40:29+02:00” But when I try: $isoDate = CarbonCarbon::now()->format(‘c’); as I understood passing a c to format function …