Skip to content

Instantly share code, notes, and snippets.

View webrobert's full-sized avatar

webrobert

  • California, USA
  • 07:27 (UTC -07:00)
View GitHub Profile
@webrobert
webrobert / Docusign.php
Last active February 24, 2023 20:59
never mind me
<?php
namespace App\Services;
use DocuSign\eSign\Api\EnvelopesApi;
use DocuSign\eSign\Client\ApiClient;
use DocuSign\eSign\Model\CompositeTemplate;
use DocuSign\eSign\Model\Document;
use DocuSign\eSign\Model\EnvelopeDefinition;
use DocuSign\eSign\Model\InlineTemplate;
@webrobert
webrobert / wygiwys-editor.examples.md
Last active October 7, 2024 15:37
wygiwys editor examples with laravel livewire

Working WYGIWYS editor examples for Livewire 2

As a reference for questions I've answered on Laracasts for how to get WYGIWYS editors working....

Trix

// components/input-rich-text.blade.php
@props(['initialValue' => ''])

<div x-data="{ content: @entangle($attributes->wire('model')).defer }">
    <input type="hidden" id="x" value="{{ $initialValue }}" />
DocuSign\eSign\Model\EnvelopeDefinition {#924 ▼ // app/Services/Docusign.php:90
  #container: array:89 [▼
    // ...
    "composite_templates" => array:5 [▼
      0 => DocuSign\eSign\Model\CompositeTemplate {#923 ▼
        #container: array:5 [▼
          "composite_template_id" => "1" // tried using the same id for each composite_template and also incementing
          "document" => DocuSign\eSign\Model\Document {#841 ▼
            #container: array:27 [▼
@webrobert
webrobert / dropbox_laravel_tokens.md
Last active October 26, 2023 16:33
New up Dropbox tokens in Laravel

Dropbox, What, no way to get a long-lived token!?

So I was thinking how cool the Dropbox adapter is for filesystem. Then the token expired.

My app isn't client facing (It's an api for moving files between our systems). We don't have users that OAuth to get new tokens. I am wondering how others are handling this?

My solution (and tell me if there is a better method) was to add a cached call using the refresh method that is floating around the net... and the manual way since I just need the damn refresh_token (to new up tokens).

First, use your own <APP_KEY> and paste this url in a browser to get a code

@webrobert
webrobert / resetToZeroAtLength.md
Created January 13, 2023 23:29
reset to zero at length
  $repeat = ['one', 'two', 'three', 'four'];
  $key = 0;
  $x = 0;

  while($x <= 27) {
      echo "{$repeat[$key]}<br/>";
      $key = ++$key % count($repeat); // reset to zero when length is met
 $x++;
@webrobert
webrobert / usingPadandTimes.md
Last active February 3, 2023 00:20
Calendar with Carbon and pad()

When I’ve got some time I like to read Helpers and Collections in the laravel docs.

Partly because I’m a geek and partly because it seems like sometimes I don’t get it until I have a use case.

Recently I wanted to render a calendar. I found a use for two new methods times() which skips the need for collecting a range and pad() to continue rendering elements in a blade loop even when empty. Or in this first example. It let me create empty days for the start of the month (based on the day of week a month starts)...

// Carbon $date
$startDay = (int) $date-&gt;firstOfMonth()-&gt;isoFormat('d');
@webrobert
webrobert / checkUrlsAreValid.md
Last active January 13, 2023 23:36
a code snippet for using Pool Client to check urls are valid. It was an answer I wrote for laracasts.

Use Http Pool Client to check urls are valid.

This was orginally an answer I wrote for Laracasts.

$urls = collect([
    'http://google.com',
    'http://googsdfsdle.com',
    'http://yelp.com',
    'http://testwwerer.com',
@webrobert
webrobert / Model.php
Last active December 29, 2022 18:24
Laravel Dynamic Relationship Or Column
<?php
// create a dynamic relationship (when there isnt a column to relate to... make one dynamicly!)
public function scopeWithLastLogin($query)
{
$query->addSelect(['last_login_id' => Login::select('id')
->whereColumn('user_id', 'users.id')
->latest()
->take(1)
])->with('lastLogin');
@webrobert
webrobert / LegalController.php
Last active December 4, 2022 23:12
A markdown driven Legal pages for my Laravel sites.
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Route;
use Illuminate\Mail\Markdown;
use Illuminate\Support\Str;
use Illuminate\View\View;
class LegalController extends Controller
@webrobert
webrobert / README.md
Last active June 9, 2024 01:45
A simple Laravel-Livewire Pikaday date-range picker using Alpine

A simple Laravel-Livewire Pikaday date range picker using Alpine

I wanted a blade component for date-range where the two dates reference one another. There is probably a cleaner way to do this. I'm all ears...

Usage with any two wire:model dates...

<x-date-range-picker class="flex items-end">
  <x-slot name="start_date" wire:model="todo.start_date"></x-slot>