Skip to content

Instantly share code, notes, and snippets.

View willchambers99's full-sized avatar

Will Chambers willchambers99

View GitHub Profile
@willchambers99
willchambers99 / main.js
Created March 18, 2020 11:06
a template for a vue project
import Vue from 'vue'
import App from './App'
import router from 'router'
import vuetify from './plugins/vuetify'
Vue.config.productionTip = false
new Vue({
router,
vuetify,
@willchambers99
willchambers99 / router.js
Created March 18, 2020 10:51
A skeleton for creating a router file
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
]
const router = new VueRouter( {
@willchambers99
willchambers99 / web.php
Created March 4, 2020 11:12
Redirect any laravel route to controller that returns view for SPA.
Route::get('/{any}', 'SpaController@index')->where('any', '.*');
@willchambers99
willchambers99 / taggingInputComponent.vue
Created February 25, 2020 15:35
A simple vue js component for tagging items using an input.
<template>
<div class="tag-input">
<div v-for='(tag, index) in tags' :key='tag' class='tag-input__tag'>
<span @click="removeTag(index)">x</span>
{{ tag }}
</div>
<input
type="text"
placeholder="Enter a tag"
class="tag-input__text"
@willchambers99
willchambers99 / dragDropComponent.vue
Last active February 25, 2020 14:17
Drag and drop component for vue js.
<template>
<div class="drag-and-drop">
<div class="drop-zone"
@drop='onDrop($event, 1)'
@dragover.prevent
@dragenter.prevent>
<div
class='drag-el'
v-for='item in listOne'
:key='item.title'
@willchambers99
willchambers99 / yajraUsersTable
Created January 30, 2020 16:56
How to construct your view for yajra datatables.
<div class="users-div">
<div class="table-responsive" style="width: 100.8%">
<table class="users-table cell-border">
<thead>
<th>User ID</th>
<th>Name</th>
<th>Actions</th>
</thead>
</table>
</div>
<?php
namespace App\Http\Controllers;
use App\Services\SomeApiService;
use Yajra\Datatables\Datatables;
class DatatablesController extends Controller
{
private $api;
@willchambers99
willchambers99 / apiwrapper
Last active February 26, 2020 10:01
Example PHP service that can be used to implement an API.
<?php
namespace App\Services;
use Illuminate\Support\Facades\Log;
use Http\Factory\Discovery\HttpClient;
use WillChambers\Api\SomeApi;
use WillChambers\Configuration;
class DatastoreService
@willchambers99
willchambers99 / homestead.yaml
Created January 30, 2020 16:17
Example homestead.yaml for setting up vagrant
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
ssl: true
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
@willchambers99
willchambers99 / crupdate
Last active January 30, 2020 16:14
Store or update in one function
<?php
public function crupdate($id = null, Request $request)
{
$fields = $request->only(['field_1', 'field_2']);
$model = Model::updateOrCreate(
[
'id' => $id
],