Best code snippets, tutorials and more

Coursecomp is your starting point for developing and maintaining your web application.

How to change VS Code Intellisense keyboard shortcut in MacOS

If you ever wondered how to use your VSCode Intellisense shortcut while having a Control + Space assigned to a Spotlight Search – I have got you covered. First, you want to go to keyboard shortcuts settings in VSCode (Cog icon > Keyboard Shortcuts) or simply pressing Cmd + K + S. In the resulting […]

How to use rate limiting in Laravel

It is almost always a better idea not to use IP as part of rate limiting in Laravel. The main reason for that it can be easily changed with proxies and VPNs. Did you know that there is an elegant syntax for multiple rate limiters in Laravel? Here they are: This code will not help […]

How to make Codepen-like button with animated gradient border

In previous post, we showed how to make gradient border with CSS. This time, we go a little bit further. Let’s take a look at the beautiful button “Start coding” on homepage (you have to be logged out to see it). It also animates beautifully on mouse over: Here you are, beautiful button: See […]

How to use gradients for borders in CSS

The border-image-source property allows you to set a trendy gradient for the element’s border. Try it on Codepen. Remember, this code does not work with the border-radius property because it is not supported with border-image. If you want to have rounded borders, you can try this code: See Codepen

How to use whereRelation method in Laravel

Laravel tip. You can use the whereRelation method (introduced in Laravel 8.57+) instead of whereHas when filtering by a simple where statement. The only downside is that you cannot use scopes, whereRelation is suitable for only one simple “where” statement. The merit of using whereRelation is shorter and more readable syntax, and in terms of […]

How to render SVG with Blade components in Laravel

Laravel is a very flexible framework, and you can reutilize your Blade components when it comes to SVG rendering. You can use {{ $.attributes }} in the component itself to pass custom attributes like (e.g., “class”). Just look at the following syntax: File structure: Helpful tip If you see the use of href="#!" and have […]

How to use conditions in Laravel Eloquent

Eloquent is a brilliant ORM – you can use conditions in relationships. In this example, we have multiple users. In the next step, we set a relationship called admins which extends the user relation with a condition. So easy! But you have to be mindful when creating a user via admins relationship. You will need […]

How to push jobs to the queue in Laravel (Cheat sheet)

Here is the cheat sheet on the ways you can push jobs to queue in your Laravel application: If you are configuring Laravel Queues with AWS SQS, and you want to queue a job later than 15 minutes in the future, you may want to use the Laravel Haystack package. You can also use the Bus::chain method […]