Skip to content

Instantly share code, notes, and snippets.

<template>
<div>
</div>
</template>
<script>
import base from 'navbar/navbar';
export default {
mixins: [
base
],
<!-- NavBar For Authenticated Users -->
<main-nav
:user="user"
:teams="teams"
:current-team="currentTeam"
:has-unread-notifications="hasUnreadNotifications"
:has-unread-announcements="hasUnreadAnnouncements"
:nav-open="navOpen"
:dropdown-open="dropdownOpen"
inline-template>
<div class="">
<!-- User Photo / Name -->
<a href="#" @click.prevent="toggleDropdown" class="px-4 hover:no-underline focus:no-underline" role="button" aria-expanded="false">
<img :src="user.photo_url" class="spark-nav-profile-photo m-r-xs">
<span class="caret"></span>
</a>
@include('nav.dropdown')
</div>
fetchUrl() {
return axios.get('https://api.github.com/repos/tnorthcutt/member-score-wp-plugin/releases/latest')
.then(function (response) {
return response.data.assets[0].browser_download_url;
});
},
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': Spark.csrfToken
};
setPluginUrl() {
// Deleting the default header
delete window.axios.defaults.headers.common['X-CSRF-TOKEN'];
// Calling the method that fetches the data from Github
this.fetchUrl().then(data => {
this.pluginUrl = data;
});
// Reset the axios default headers
@tnorthcutt
tnorthcutt / app.blade.php
Created December 10, 2018 01:02
Limiting user tracking in a Laravel Spark app to real users signed into the app (not admins or admins impersonating a user)
<script>
<?php if (Auth::user() && Spark::developer(Auth::user()->email) || session('spark:impersonator')) {
?> Spark.state.devmode = true; <?php
} else {
?> Spark.state.devmode = false; <?php
} ?>
if (Spark.state.user && !Spark.state.devmode) {
// Intercom, FullStory, etc. tracking goes here
}

UsedByTeams Model Trait For Laravel Spark

Automatically limit your models to the current team

So you're using spark, and you have teams enabled. You start creating models and want to have them be team specific. Instead of writing, Model::where('team_id', auth()->user()->currentTeam->id)->get(); use this trait to add that behind the scenes so that every time you call on your model, it's assumed that you mean for the current team.

This assumes that the model has a team_id, while it adds a scope of where team_id = currentTeam->id.

Note: Implicit Route Model Binding in 5.2, auth session doesn't exist at the point of this trait causing issue. fixed in 5.3

@tnorthcutt
tnorthcutt / Member.php
Created April 11, 2019 22:13
Extending spatie/laravel-tags to limit to the current team in a Spark application
<?php
// Relevant parts of my Member.php model, which is the model that I'm applying tags to
/**
* Using our own Tag model
* @see https://docs.spatie.be/laravel-tags/v2/advanced-usage/using-your-own-tag-model
*
* @return string
*/
@tnorthcutt
tnorthcutt / rm_mysql.md
Created April 24, 2019 14:52 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql