Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Belz belzaaron

View GitHub Profile
@belzaaron
belzaaron / SomeServiceProviderBootMethod.php
Last active Jan 21, 2021
Alpine JS and Clipboard.JS Laravel Blade Directive
View SomeServiceProviderBootMethod.php
<?php
Blade::directive('clickToCopy', function ($expression) {
return 'x-data="{ copy: \'{{ '.$expression.'}}\' }" x-init="new ClipboardJS($el, { container: $el.parentElement, text() { return copy; } })"';
});
@belzaaron
belzaaron / CollectionPaginateMacro.php
Created Oct 24, 2020
A macro to allow collections to be paginated.
View CollectionPaginateMacro.php
Collection::macro('paginate', function (int $perPage = 15, $page = null, array $options = []): LengthAwarePaginator {
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
return new LengthAwarePaginator(
$this->forPage($page, $perPage),
$this->count(),
$perPage,
$page,
$options
);
View BladeFaviconDirective.php
Blade::directive('favicons', function () {
$string = '<link rel="apple-touch-icon" sizes="180x180" href="'.asset('/apple-touch-icon.png').'">';
$string .= '<link rel="icon" type="image/png" sizes="32x32" href="'.asset('/favicon-32x32.png').'">';
$string .= '<link rel="icon" type="image/png" sizes="16x16" href="'.asset('/favicon-16x16.png').'">';
$string .= '<link rel="manifest" href="'.asset('/site.webmanifest').'">';
$string .= '<link rel="mask-icon" href="'.asset('/safari-pinned-tab.svg').'" color="#32bea6">';
$string .= '<meta name="msapplication-TileColor" content="#2ebfa7">';
$string .= '<meta name="theme-color" content="#32bea6">';
return $string;
});
@belzaaron
belzaaron / README.md
Created Jul 16, 2019
A good starter README
View README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

View main.json
[{
"name": "Priority: Low",
"color": "#009800"
},
{
"name": "Priority: Medium",
"color": "#fbca04"
},
{
"name": "Priority: High",