Skip to content

Instantly share code, notes, and snippets.

@shaneparsons
Last active March 27, 2019 18:23
Show Gist options
  • Save shaneparsons/46cb81f1ce1223d20ed98593fddeaf76 to your computer and use it in GitHub Desktop.
Save shaneparsons/46cb81f1ce1223d20ed98593fddeaf76 to your computer and use it in GitHub Desktop.
Various snippets for Laravel

Show duplicate rows

$dupes = $items->diff($items->unique('name'));
return $dupes;

Limit results

$items = Item::limit(60)->get();

Passport

Create personal access token

artisan passport:client --personal

Add user to personal access token

$user = App\User::find(1);
$token = $user->createToken('name', ['scope'])->accessToken;

return '<pre>' . $token .'</pre>';

Artisan

Create migration, factory, controller, model

php artisan make:model Name -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment