pascual

Member Since 2 Years Ago

Experience Points
20,730
Total
Experience

4,270 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
188
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 5
20,730 XP
May
07
1 week ago
Activity icon

Replied to Laravel 8 Seeder Factory : Call To A Member Function Count() On Null

Hello,

The error message means that $factory is null, which in your case at line 15 would mean that Factory::factoryForModel(get_called_class()) returns null.

Seeing that this originates from framework code, I suspect that there is something wrong in your seeder.

We might find the cause if you paste what is inside your UserSeeder.php

May
06
1 week ago
Activity icon

Replied to How In Laravel 8 With Tailwind CSS Define Backend.css Which Overwrite App.css?

I am in no way an expert at these types of customizations with Tailwind, but it seems to me that the problem here might be that you try to define app_main_color after Tailwind has done its thing.

As the error message states:

make sure that any `@import` statements are being properly processed before Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.

I had a look at one of my own app.css using Tailwind and some imports, and there we have the imports before the Tailwind classes.

Example:

@import url('https://fonts.googleapis.com/css?family=Nunito:200,400');
@import url('https://fonts.googleapis.com/css?family=Libre+Baskerville');
@import url('https://fonts.googleapis.com/css?family=Francois+One&subset=latin-ext');

@tailwind base;
@tailwind components;
@tailwind utilities;
Activity icon

Replied to Change Password At First Login

I have not studied that package in detail, but it seems like it was made with that in mind.

Best of luck with your project!

May
05
1 week ago
Activity icon

Awarded Best Reply on Change Password At First Login

I agree with @corvs here, but I was so sure that the exact behavior you are looking for here @sinres was implemented as a middleware in Illuminate/Auth last year.

I must have been dreaming though, because I have been googling like crazy now and I can not find any reference to it.

I thought I might have heard about it at the Laravel News Podcast, and I did find something there that might help you accomplish this without writing everything from scratch.

Laravel News: Send Users a Welcome Notification to Set an Initial Password

The package in question is one made by Spatie, and it is called laravel-welcome-notification

Activity icon

Replied to Change Password At First Login

I agree with @corvs here, but I was so sure that the exact behavior you are looking for here @sinres was implemented as a middleware in Illuminate/Auth last year.

I must have been dreaming though, because I have been googling like crazy now and I can not find any reference to it.

I thought I might have heard about it at the Laravel News Podcast, and I did find something there that might help you accomplish this without writing everything from scratch.

Laravel News: Send Users a Welcome Notification to Set an Initial Password

The package in question is one made by Spatie, and it is called laravel-welcome-notification

May
04
1 week ago
Activity icon

Replied to Load Schema In Testing

I don't know your specific use case, but I you run into problems using data dumps from a production site when doing local testing that could be an issue in itself in several ways.

Keeping a separate set of dummy data for testing in development have a lot of advantages in my opinion, and can be quite easily done using seeders.

There was quite an interesting talk about this in the latest Laravel News Podcast.

Laravel News Podcast #141

Article: Why Dummy Data Matters

Another discussion on the topic in this forum

Activity icon

Replied to Where Are You All From?

Bergen, Norway.

Activity icon

Replied to Load Schema In Testing

Are you sure that your testing environment is using the same database connection as the application? Check your phpunit.xml config file for that.

Activity icon

Replied to Run Console Command After First Complete

Is your question how to have a second command run after the first one has completed?

Activity icon

Replied to Can't Update Array Data In Laravel

Your SQL server seems to be telling you that it can't find the column nationalCode in the table kycs. And from the migration you have enclosed it seems in fact to be missing. Could you have added the column in a later migration that you have forgotten to migrate?

Apr
27
2 weeks ago
Activity icon

Replied to How To Make In Laravcel With Mailchimp Some Functionality ?

Hi there!

Maybe let's first try to isolate the different things you would like to achieve into smaller units. I know from my own experience that I sometimes complicate stuff by mixing several ideas together, and it usually helps to dissect them and look at them one by one.

From what I understand you are looking to:

  • Log when an ad is created
  • Summarize the logs daily and transform this into a report
  • Send the report to the relevant users through the MailChimp API you have installed
  • Use your Laravel Blade templates and MailChimp templates in an automated way?
Activity icon

Replied to Some Thoughts On REST Naming Conventions For Singletons

It was me thinking out loud and wondering if anyone else had any thoughts on naming conventions for singleton sets in REST.

Thanks for trying though. I think I will REST my case until I am able to describe it coherently. 😆

Cheers

Activity icon

Replied to AJAX POST 500 Internal Server Error

As @michaloravec said, see the error log file for information about what went wrong.

The HTTP 500 error means that something went wrong on the server while processing your request and it could not find a more specific error to return. Usually you will always find good information in the server error log when a 500 occurs.

Activity icon

Replied to Some Thoughts On REST Naming Conventions For Singletons

Sorry for not replying, I have not received or seen any notifications from this thread.

Thank you for your detailed input, @martinbean

As to my use of the term singleton, let me try to explain myself a bit better than in my previous post. I am aware of the single design pattern, but that was not what I was referring to. I was referring to the mathematical concept of a singleton (sometimes also called a unit set).

Within category theory this is very useful as the mathematical definition of a singleton is a set with the cardinality (number of elements) of only one, and always only one. And the topic I tried to think aloud about in my original post was the category theory that is REST.

Still using mathematical terms a set would be a collection of elements where the elements are distinguishable from each other. Using the REST approach, say we have a route called /blog-posts. A GET request to this route could return a set of all blog posts.

We could represent this using this notation (where B is blog posts and i is its unique ID):

B = {i, ...}

This set notation tells us that a any set of blog posts consists of 1 or infinity number for distinct blog posts. For the purpose of simplicity I had left out the possibility of the state where there are zero posts, which could perfectly well be the case at any given time of course.

This approach is extremely well suited for REST and working with the target's representational state.

A call to /blog-posts/99 also makes perfect sense because we know that it is a reference to a single, distinct item in the set.

However, the thing that gives of a bit a smell to me is when REST is used to refer to a singleton (as in a mathematical singleton).

The definition of a set that is a singleton is if, and only if, it has the cardinality of one. In a software application I can think of several cases where they would appear, especially if we factor in that the routes an end-user and an admin might have very different levels of utility value respectively. The route /users yielding a list of all users could be very useful for an administrator, but might not even be accessible to the end-user. In these cases the cardinality will always be one, ergo they will always be singletons.

Then what is it I am going on about then? Most best practices on how to apply REST to your API tells you to use a plural form for the resource name. See for instance REST API Naming Conventions and Best Practices Well, then let's examine the example of the concept of a user profile. To an admin it could make sense to view the metadata that makes up a single user profile, and that might be achieved with the route /users/1 to get the data for the user with the distinct ID of 1. Same as for the blog posts example above the distinct value 1 would refer to a distinct user within the users set:

USERS = {1, ...}

The route for the end user to access his profile (the meta data that is the profile) could for simplicity be named /profile, but this would be impossible to achieve statelessly. There is no way of distinguishing between different user profiles solely based on the URI.

We could use the route /users/1 or even /users/profiles/1

But to the end user the concept of a set collection of more than one user profile does not make sense. The user is by itself a single distinct item and has a 1-to-1 relationship with the profile. For user 1 to increment URI /user/1 to user/2 would only make sense if the user was trying to illegally access another user's profile.

The notation of the singleton concept of a user profile could be: P = {n+1} using the set theoretic definition of natural numbers. A user profile will therefore always have the cardinality of one.

Just as /users in admin land makes sense and can be represented as U = {0, ...} , /users in end user land would probably be an illegal route endpoint. But this logic seem to be tossed overboard when a single item from the set collection is to be returned. The admin accesses a single user by using the route /users/1 and so also does the end user and framework logic would prevent the user from accessing other user's profiles.

And this is what grinds my gears. The resources in REST are not supposed to be mapped to an entity but a set of entities. The resource invoices could have the URI /invoices and would map to a set collection of 0,1 or an infinite number of invoices. This logic breaks when the set collection is a singleton because it does not make sense to refer to a singleton by a distinct identity because there is only one of it. Using an id implies that it is not in fact a singleton.

Does it really matter?

Seeing that designing routes in a web application is based on very loose rules, it probably does not matter at all. But one of the objectives behind designing RESTful API's is to improve overall quality by being consistent. To me, just ignoring a logical flaw and hack around it is far from trying to be consistent. It at least gives off a smell that should be considered doing something about.

Huge disclaimer

I am in absolutely no way a mathematician nor a computer scientist, so I might very well have these concepts and ideas wrong. Feel free to correct me if needed.

Activity icon

Replied to Many Controller In One View

Hi there!

Seeing that the controller in a traditional MVC pattern will be responsible for calling the view, often after consult with one or several models this should be perfectly doable.

However, unless you have setup route model binding I think we will need to see the controller in question to help you with the specific problem you are facing.

Mar
11
2 months ago
Activity icon

Started a new Conversation Some Thoughts On REST Naming Conventions For Singletons

Hello everyone, I have been pondering on some general thoughts regarding the topic of REST naming conventions when dealing with singletons.

It seems to be that most of the advice and best practices on the subject is from the viewpoint of an enduser with an extensive access to the final application. Let me try to explain what I mean. I might be overlooking something very fundamental here, so I would be extremely grateful if anyone would share their thoughts with me.

A typical "happy path" example

In the domain of "users", users would be a collection of users and a user would be a singleton representing a specific user.

Typically, if following the usual conventions, the routing for accessing these would be something like this:

// Get a collection of some or all users.
Route::get('/users', [UsersController::class, 'index']);

// Get a single user using a unique identifier explicitly.
Route::get('/users/{id}',  [UsersController::class, 'show']);

// Get a single user using route model binding.
Route::get('/users/{user}',  [UsersController::class, 'show']);

The above example will is an example of how that convention would be used, and can be applied to countless use cases. The Laracasts video on this in the Laravel from scratch course elaborates on this.

The problem

However, to me there is a problem with this convention and I can't seem to figure out a way to address it without straying away from said conventions.

When put in the context of someone using the application I see a problem when differentiating between different types of end users. A user the should be able to handle both a collection and a singleton is easy to write RESTful solutions for, just see above. But for the user that should only be able to access a singleton I see a problem.

To the user with the user id 69, the url /users/69 doesn't really make sense if said user should never be able to access any other user singletons. Having a route for /users/{id} implies that there could be several available, and incrementing or decrementing the value could might yield access. This implication only makes sense for someone give the permission to access several singletons, to anyone else it is never an option. And if the url should convey semantic information, the convention discussed here makes for bad practise when dealing with the case when an enduser is to access his only available singleton.

Sure, you can't protect the routes, but in my opinion this is a lesser solution when we are striving for stringent conventions as to naming.

That user might access his singleton by accessing /home/profile for instance, and using the convention the only way to represent state then would be to access that information without the url, for instance using session values.

How are you handling this in a coherent and consistent manner in your routes, dear people?

Feb
04
3 months ago
Activity icon

Commented on Initial Database Setup With Seeding

@alqahtani Thanks bro. That was really helpful and generous of you!