Skip to content

Instantly share code, notes, and snippets.

@withchandra
withchandra / #readme.md
Last active July 9, 2024 09:04
Laravel + PHP CS Fixer + Prettier + ESLint + airbnb-base + Husky + lint-staged + commitlint + pre-commit hook + pre-push hook

This is my personal setup for linting and repo branches protection for a new laravel project. Feel free to copy and adjust.

Reason

I am using both bitbucket and github for mostly private projects, while bitbucket allows private repo to use advance features such as branch permission, github limit their protected branch feature for free-user.

On the other hand, implementing standard linting for both JS and PHP will help code-reviewer to read and evaluate the code.

Last but not least, standardized commit message will make everybody happy. =)

@whoisryosuke
whoisryosuke / incrementing-slugs.php
Last active March 21, 2022 13:17
Laravel: Check database for duplicate slugs and generate incrementing slug name (repeat-name-2, repeat-name-3). Found via: https://codereview.stackexchange.com/questions/162254/append-a-incrementing-number-to-a-slug-username
<?php
protected function create(array $data)
{
$slug = str_slug($data['first_name'] . '.' . $data['last_name']);
$next = 2;
// Loop until we can query for the slug and it returns false
while (User::where('slug', '=', $slug)->first()) {
$slug = $slug . '-' . $next;
$next++;
@dlordi
dlordi / no-favicon-req.html
Created October 11, 2013 13:22
HTML: disable favicon request
<head>
<link rel="shortcut icon" href="#" />
</head>