1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 11:14:03 +00:00
This commit is contained in:
Samuel Štancl 2019-08-16 22:09:01 +02:00
commit a92690cea8
61 changed files with 51214 additions and 0 deletions

15
source/404.blade.php Normal file
View file

@ -0,0 +1,15 @@
@extends('_layouts.master')
@section('body')
<div class="flex flex-col items-center mt-32 text-grey-darker">
<h1 class="text-6xl font-light leading-none mb-2">404</h1>
<h2 class="text-3xl">Page not found</h2>
<hr class="block w-full max-w-sm mx-auto my-8 border">
<p class="text-xl">
Need to update this page? See the <a title="404 Page Documentation" href="https://jigsaw.tighten.co/docs/custom-404-page/"> Jigsaw documentation</a>.
</p>
</div>
@endsection

17
source/_assets/js/main.js Normal file
View file

@ -0,0 +1,17 @@
window.docsearch = require('docsearch.js');
import hljs from 'highlight.js/lib/highlight';
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'));
hljs.registerLanguage('css', require('highlight.js/lib/languages/css'));
hljs.registerLanguage('html', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'));
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'));
hljs.registerLanguage('markdown', require('highlight.js/lib/languages/markdown'));
hljs.registerLanguage('php', require('highlight.js/lib/languages/php'));
hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss'));
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'));
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});

View file

@ -0,0 +1,130 @@
body {
font-size: 17px;
}
a {
@apply .font-semibold;
@apply .no-underline;
@apply .text-blue-dark;
&:hover {
@apply .text-blue-darker;
}
}
blockquote {
@apply .border-blue-light;
@apply .border-l-4;
@apply .font-normal;
@apply .italic;
@apply .my-8;
@apply .pl-6;
@apply .text-grey-darker;
@apply .text-lg;
}
code {
@apply .bg-grey-light;
@apply .px-2;
@apply .py-px;
@apply .rounded;
@apply .text-sm;
}
code.hljs {
@apply .bg-transparent;
@apply .p-0;
.hljs-comment,
.hljs-keyword,
.hljs-meta {
@apply .font-normal;
@apply .roman;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
@apply .leading-tight;
@apply .mb-4;
@apply .mt-8;
@apply .text-black;
&:first-child {
@apply .mt-0;
}
}
h1 {
@apply .font-extrabold;
@apply .text-5xl;
}
h2 {
@apply .font-bold;
@apply .text-4xl;
}
h3 {
@apply .font-bold;
@apply .text-3xl;
}
h4 {
@apply .font-normal;
@apply .text-2xl;
}
h5 {
@apply .font-normal;
@apply .text-xl;
}
h6 {
@apply .font-light;
@apply .text-lg;
}
hr {
@apply .border-b;
@apply .border-blue-lighter;
@apply .my-12;
@apply .rounded-full;
}
li {
ul,
ol {
@apply .my-0;
}
}
ol,
ul {
@apply .my-4;
}
p {
@apply .my-6;
}
pre {
@apply .bg-grey-lighter;
@apply .leading-loose;
@apply .my-6;
@apply .overflow-x-auto;
@apply .p-4;
@apply .rounded;
@apply .shadow;
@apply .text-base;
code {
@apply .bg-transparent;
@apply .block;
@apply .p-0;
}
}

View file

@ -0,0 +1 @@
// Add your custom styles here

View file

@ -0,0 +1,34 @@
.nav-menu {
@apply .-mt-12;
@apply .-mx-8;
@apply .bg-grey-lighter;
@apply .mb-8;
@apply .pb-4;
@apply .pt-8;
@apply .px-4;
@apply .shadow;
@apply .w-auto;
@screen lg {
@apply .-mx-4;
@apply .bg-transparent;
@apply .block;
@apply .border-b-0;
@apply .mt-1;
@apply .pl-0;
@apply .pr-4;
@apply .pt-0;
@apply .shadow-none;
@apply .w-1/4;
}
}
.nav-menu__item {
@apply .block;
@apply .list-reset;
@apply .no-underline;
@apply .mb-3;
@apply .mt-0;
@apply .text-grey-darkest;
@apply .text-sm;
}

View file

@ -0,0 +1,76 @@
.docsearch-input {
background-image: url('/assets/img/magnifying-glass.svg');
background-position: 0.8em;
background-repeat: no-repeat;
text-indent: 1.2em;
@screen lg {
&:focus {
@apply .w-2/3;
}
}
@screen xl {
&:focus {
@apply .w-1/2;
}
}
&__wrapper {
@apply absolute;
@apply bg-white;
@apply mt-7;
@apply pin-l;
@apply pin-t;
@apply px-4;
@apply w-full;
@apply z-10;
@screen md {
@apply mt-0;
@apply px-0;
@apply relative;
}
}
}
.algolia-autocomplete {
@apply .text-right;
@apply .w-full;
.ds-dropdown-menu {
@apply .w-full;
max-width: 750px !important;
min-width: auto !important;
.algolia-docsearch-suggestion {
.algolia-docsearch-suggestion--content {
@apply .w-full;
@screen md {
@apply .w-2/3;
}
}
.algolia-docsearch-suggestion--text {
@apply .font-normal;
line-height: 1.4;
}
.algolia-docsearch-suggestion--wrapper {
@apply .py-3;
}
.algolia-docsearch-suggestion--subcategory-column {
@apply .hidden;
@screen md {
@apply .w-1/3;
@apply .inline-block;
}
}
}
}
}

View file

@ -0,0 +1,13 @@
@tailwind preflight;
@tailwind components;
// Code syntax highlighting,
// powered by https://highlightjs.org
@import '~highlight.js/styles/a11y-light.css';
@import 'base';
@import 'navigation';
@import 'documentation';
@import 'search';
@tailwind utilities;

View file

@ -0,0 +1,19 @@
@extends('_layouts.master')
@section('nav-toggle')
@include('_nav.menu-toggle')
@endsection
@section('body')
<section class="container max-w-4xl mx-auto px-6 md:px-8 py-4">
<div class="flex flex-col lg:flex-row">
<nav id="js-nav-menu" class="nav-menu hidden lg:block">
@include('_nav.menu', ['items' => $page->navigation])
</nav>
<div class="w-full lg:w-3/5 break-words pb-16 lg:pl-4" v-pre>
@yield('content')
</div>
</div>
</section>
@endsection

View file

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="{{ $page->description ?? $page->siteDescription }}">
<meta property="og:site_name" content="{{ $page->siteName }}"/>
<meta property="og:title" content="{{ $page->title ? $page->title . ' | ' : '' }}{{ $page->siteName }}"/>
<meta property="og:description" content="{{ $page->description ?? $page->siteDescription }}"/>
<meta property="og:url" content="{{ $page->getUrl() }}"/>
<meta property="og:image" content="/assets/img/logo.png"/>
<meta property="og:type" content="website"/>
<meta name="twitter:image:alt" content="{{ $page->siteName }}">
<meta name="twitter:card" content="summary_large_image">
@if ($page->docsearchApiKey && $page->docsearchIndexName)
<meta name="generator" content="tighten_jigsaw_doc">
@endif
<title>{{ $page->siteName }}{{ $page->title ? ' | ' . $page->title : '' }}</title>
<link rel="home" href="{{ $page->baseUrl }}">
<link rel="icon" href="/favicon.ico">
@stack('meta')
@if ($page->production)
<!-- Insert analytics code here -->
@endif
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,300i,400,400i,700,700i,800,800i" rel="stylesheet">
<link rel="stylesheet" href="{{ mix('css/main.css', 'assets/build') }}">
@if ($page->docsearchApiKey && $page->docsearchIndexName)
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
@endif
</head>
<body class="flex flex-col justify-between min-h-screen bg-grey-lightest text-grey-darkest leading-normal font-sans">
<header class="flex items-center shadow bg-white border-b h-24 mb-8 py-4" role="banner">
<div class="container flex items-center max-w-4xl mx-auto px-4 lg:px-8">
<div class="flex items-center">
<a href="/" title="{{ $page->siteName }} home" class="inline-flex items-center">
<img class="h-8 md:h-10 mr-3" src="/assets/img/logo.svg" alt="{{ $page->siteName }} logo" />
<h1 class="text-lg md:text-2xl text-blue-darkest font-semibold hover:text-blue-dark my-0 pr-4">{{ $page->siteName }}</h1>
</a>
</div>
<div class="flex flex-1 justify-end items-center text-right md:pl-10">
@if ($page->docsearchApiKey && $page->docsearchIndexName)
@include('_nav.search-input')
@endif
</div>
</div>
@yield('nav-toggle')
</header>
<main role="main" class="w-full flex-auto">
@yield('body')
</main>
<script src="{{ mix('js/main.js', 'assets/build') }}"></script>
@stack('scripts')
<footer class="bg-white text-center text-sm mt-12 py-4" role="contentinfo">
<ul class="flex flex-col md:flex-row justify-center list-reset">
<li class="md:mr-2">
&copy; <a href="https://github.com/stancl" title="Samuel Štancl">Samuel Štancl</a> {{ date('Y') }}.
</li>
<li>
Built with <a href="http://jigsaw.tighten.co" title="Jigsaw by Tighten">Jigsaw</a>
and <a href="https://tailwindcss.com" title="Tailwind CSS, a utility-first CSS framework">Tailwind CSS</a>.
</li>
</ul>
</footer>
</body>
</html>

View file

@ -0,0 +1,18 @@
<li class="list-reset pl-4">
@if ($url = is_string($item) ? $item : $item->url)
{{-- Menu item with URL--}}
<a href="{{ $page->url($url) }}"
class="{{ 'lvl' . $level }} {{ $page->isActiveParent($item) ? 'lvl' . $level . '-active' : '' }} {{ $page->isActive($url) ? 'active font-semibold text-blue' : '' }} nav-menu__item hover:text-blue"
>
{{ $label }}
</a>
@else
{{-- Menu item without URL--}}
<p class="nav-menu__item text-grey-dark">{{ $label }}</p>
@endif
@if (! is_string($item) && $item->children)
{{-- Recursively handle children --}}
@include('_nav.menu', ['items' => $item->children, 'level' => ++$level])
@endif
</li>

View file

@ -0,0 +1,29 @@
<button class="flex justify-center items-center bg-blue border border-blue h-10 mr-4 px-5 rounded-full lg:hidden focus:outline-none"
onclick="navMenu.toggle()"
>
<svg id="js-nav-menu-show" xmlns="http://www.w3.org/2000/svg"
class="fill-current text-white h-9 w-4" viewBox="0 0 32 32"
>
<path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/>
</svg>
<svg id="js-nav-menu-hide" xmlns="http://www.w3.org/2000/svg"
class="hidden fill-current text-white h-9 w-4" viewBox="0 0 36 30"
>
<polygon points="32.8,4.4 28.6,0.2 18,10.8 7.4,0.2 3.2,4.4 13.8,15 3.2,25.6 7.4,29.8 18,19.2 28.6,29.8 32.8,25.6 22.2,15 "/>
</svg>
</button>
@push('scripts')
<script>
const navMenu = {
toggle() {
const menu = document.getElementById('js-nav-menu');
menu.classList.toggle('hidden');
menu.classList.toggle('lg:block');
document.getElementById('js-nav-menu-hide').classList.toggle('hidden');
document.getElementById('js-nav-menu-show').classList.toggle('hidden');
},
}
</script>
@endpush

View file

@ -0,0 +1,7 @@
@php $level = $level ?? 0 @endphp
<ul class="list-reset my-0">
@foreach ($items as $label => $item)
@include('_nav.menu-item')
@endforeach
</ul>

View file

@ -0,0 +1,47 @@
<button
title="Start searching"
type="button"
class="flex md:hidden bg-grey-lightest hover:bg-blue-lightest justify-center items-center border border-grey rounded-full focus:outline-none h-10 px-3"
onclick="searchInput.toggle()"
>
<img src="/assets/img/magnifying-glass.svg" alt="search icon" class="h-4 w-4 max-w-none">
</button>
<div id="js-search-input" class="docsearch-input__wrapper hidden md:block">
<label for="search" class="hidden">Search</label>
<input
id="docsearch-input"
class="docsearch-input relative block h-10 transition-fast w-full lg:w-1/2 xl:w-1/3 bg-grey-lightest outline-none rounded-full text-grey-darker border border-grey focus:border-blue-light ml-auto px-4 pb-0"
name="docsearch"
type="text"
placeholder="Search"
>
<button
class="md:hidden absolute pin-t pin-r h-full font-light text-3xl text-blue hover:text-blue-dark focus:outline-none -mt-px pr-7"
onclick="searchInput.toggle()"
>&times;</button>
</div>
@push('scripts')
@if ($page->docsearchApiKey && $page->docsearchIndexName)
<script type="text/javascript">
docsearch({
apiKey: '{{ $page->docsearchApiKey }}',
indexName: '{{ $page->docsearchIndexName }}',
inputSelector: '#docsearch-input',
debug: false // Set debug to true if you want to inspect the dropdown
});
const searchInput = {
toggle() {
const menu = document.getElementById('js-search-input');
menu.classList.toggle('hidden');
menu.classList.toggle('md:block');
document.getElementById('docsearch-input').focus();
},
}
</script>
@endif
@endpush

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,4 @@
{
"/js/main.js": "/js/main.js?id=f63a2ba71bc9fa1d173b",
"/css/main.css": "/css/main.css?id=bfeb0e0f7abaed381134"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="51px" height="44px" viewBox="0 0 51 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
<title>Group 7</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="04-docs-start-copy-3" transform="translate(-816.000000, -695.000000)">
<g id="Group-7" transform="translate(816.000000, 695.000000)">
<path d="M25.1572266,19.5799762 L1.12512399,31.5016008 L25.1572266,43.4232253 L49.1893291,31.5016008 L25.1572266,19.5799762 Z" id="Rectangle-3-Copy-3" stroke="#318AD3"></path>
<path d="M25.1572266,10.5986098 L1.12512399,22.5202343 L25.1572266,34.4418588 L49.1893291,22.5202343 L25.1572266,10.5986098 Z" id="Rectangle-3-Copy-5" stroke="#748294"></path>
<path d="M25.1572266,0.558141166 L1.12512399,12.4797657 L25.1572266,24.4013902 L49.1893291,12.4797657 L25.1572266,0.558141166 Z" id="Rectangle-3-Copy-6" stroke="#318AD3"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="37px" height="34px" viewBox="0 0 37 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
<title>terminal</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<g id="04-docs-start-copy-3" transform="translate(-497.000000, -699.000000)">
<g id="terminal" transform="translate(497.000000, 700.000000)">
<polyline id="Shape" stroke="#318AD3" points="0 27 14 13.5 0 0"></polyline>
<path d="M18,32 L36,32" id="Shape" stroke="#748294"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 856 B

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="38px" height="31px" viewBox="0 0 38 31" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
<title>Group 6</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="04-docs-start-copy-3" transform="translate(-170.000000, -702.000000)" fill-rule="nonzero">
<g id="Group-6" transform="translate(170.000000, 702.000000)">
<rect id="Rectangle-2" stroke="#318AD3" x="0.5" y="0.5" width="37" height="30" rx="3"></rect>
<rect id="Rectangle-8" stroke="#318AD3" x="0.5" y="6.5" width="37" height="1"></rect>
<rect id="Rectangle-8" stroke="#748294" x="8.5" y="23.5" width="9" height="1"></rect>
<rect id="Rectangle-8" stroke="#748294" x="8.5" y="25.5" width="9" height="1"></rect>
<rect id="Rectangle-8" stroke="#748294" x="21.5" y="23.5" width="9" height="1"></rect>
<rect id="Rectangle-8" stroke="#748294" x="21.5" y="25.5" width="9" height="1"></rect>
<rect id="Rectangle-9" stroke="#748294" x="5.5" y="11.5" width="26" height="6"></rect>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="318px" height="350px" viewBox="0 0 318 350" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
<title>Group 2</title>
<desc>Created with Sketch.</desc>
<defs>
<linearGradient x1="-83.2348064%" y1="106.401351%" x2="140.023112%" y2="-13.2029998%" id="linearGradient-1">
<stop stop-color="#F8FAFC" offset="0%"></stop>
<stop stop-color="#F8FAFC" offset="21.7972142%"></stop>
<stop stop-color="#BBDBF5" offset="100%"></stop>
<stop stop-color="#B9DAF5" offset="100%"></stop>
</linearGradient>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="04-docs-start-copy-3" transform="translate(-714.000000, -205.000000)">
<g id="Group-2" transform="translate(714.000000, 205.000000)">
<path d="M159.9,41.23566 L29.5,106.216315 L29.5,268.671884 L159.9,333.652539 L290.3,268.671884 L290.3,106.216315 L159.9,41.23566 Z" id="Rectangle-3-Copy" stroke="#B9DAF5"></path>
<polygon id="Rectangle-3-Copy-2" fill="url(#linearGradient-1)" points="129.8 186.334516 129.8 349.670807 0 284.336291 0 121"></polygon>
<path d="M317.3,186.64261 L188.5,121.811441 L188.5,284.028197 L317.3,348.859366 L317.3,186.64261 Z" id="Rectangle-3-Copy-4" stroke="#338CD6" transform="translate(252.900000, 235.335404) scale(1, -1) translate(-252.900000, -235.335404) "></path>
<path d="M159.9,41.2359725 L30.1185393,106.090062 L159.9,170.944152 L289.681461,106.090062 L159.9,41.2359725 Z" id="Rectangle-3" stroke="#B9DAF5"></path>
<path d="M159.9,0.558953879 L30.1185393,65.4130435 L159.9,130.267133 L289.681461,65.4130435 L159.9,0.558953879 Z" id="Rectangle-3-Copy-3" stroke="#338CD6"></path>
<path d="M160.175,170.953416 L160.175,332.562112" id="Line" stroke="#B9DAF5" stroke-linecap="square" fill-rule="nonzero"></path>
<path d="M160.358333,130.484509 L160.358333,165.798482" id="Line-2-Copy-3" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero"></path>
<path d="M290.158333,68.178117 L290.158333,103.49209" id="Line-2-Copy-4" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero"></path>
<path d="M133.55,185.742236 L159.95,172.549689" id="Line-2" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero"></path>
<path d="M133.55,348.742236 L159.95,335.549689" id="Line-2-Copy" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero"></path>
<path d="M292.35,283.586957 L318.75,270.39441" id="Line-2" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero" transform="translate(305.550000, 276.990683) scale(1, -1) translate(-305.550000, -276.990683) "></path>
<path d="M162.55,348.742236 L188.95,335.549689" id="Line-2-Copy-2" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero" transform="translate(175.750000, 342.145963) scale(1, -1) translate(-175.750000, -342.145963) "></path>
<path d="M291.55,119.742236 L317.95,106.549689" id="Line-2-Copy" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero" transform="translate(304.750000, 113.145963) scale(1, -1) translate(-304.750000, -113.145963) "></path>
<path d="M162.55,185.742236 L188.95,172.549689" id="Line-2-Copy-5" stroke="#C7CFDA" stroke-linecap="square" stroke-dasharray="2,4" fill-rule="nonzero" transform="translate(175.750000, 179.145963) scale(1, -1) translate(-175.750000, -179.145963) "></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
source/assets/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

View file

@ -0,0 +1,12 @@
<svg width="40px" height="45px" viewBox="0 0 40 45" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="04-docs-start" transform="translate(-170.000000, -28.000000)">
<g id="Group" transform="translate(170.000000, 28.000000)">
<polygon id="Rectangle-3-Copy" fill="#338CD6" points="20 0 40 10 40 35 20 45 0 35 0 10"></polygon>
<polygon id="Rectangle-3-Copy-2" fill="#1C3E5A" points="20 20 20 45 0 35 0 10"></polygon>
<polygon id="Rectangle-3" fill="#B9DAF5" points="20 0 40 10 20 20 0 10"></polygon>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 762 B

View file

@ -0,0 +1,8 @@
<svg width="13px" height="13px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs></defs>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(-829.000000, -42.000000)" fill="#748294" fill-rule="nonzero">
<path d="M843.319857,54.9056439 L848.707107,60.2928932 C849.097631,60.6834175 849.097631,61.3165825 848.707107,61.7071068 C848.316582,62.0976311 847.683418,62.0976311 847.292893,61.7071068 L841.905644,56.3198574 C840.55096,57.3729184 838.848711,58 837,58 C832.581722,58 829,54.418278 829,50 C829,45.581722 832.581722,42 837,42 C841.418278,42 845,45.581722 845,50 C845,51.8487115 844.372918,53.5509601 843.319857,54.9056439 Z M837,56 C840.313708,56 843,53.3137085 843,50 C843,46.6862915 840.313708,44 837,44 C833.686292,44 831,46.6862915 831,50 C831,53.3137085 833.686292,56 837,56 Z" id="Mask"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 971 B

View file

@ -0,0 +1,60 @@
---
title: Configuration
description: Configuring stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Configuration {#configuration}
The `config/tenancy.php` file lets you configure how the package behaves.
> **Note:** If the `tenancy.php` file doesn't exist in your `config` directory, you can publish it by running `php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=config`
### `storage_driver, storage`
This lets you configure the driver for tenant storage, i.e. what will be used to store information about your tenants. You can read more about this on the [Storage Drivers](storage-drivers) page.
Available storage drivers:
- `Stancl\Tenancy\StorageDrivers\RedisStorageDriver`
- `Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver`
### `tenant_route_namespace`
Controller namespace used for routes in `routes/tenant.php`. The default value is the same as the namespace for `web.php` routes.
### `exempt_domains`
If a hostname from this array is visited, the `tenant.php` routes won't be registered, letting you use the same routes as in that file.
### `database`
The application's default connection will be switched to a new one — `tenant`. This connection will be based on the connection specified in `tenancy.database.based_on`. The database name will be `tenancy.database.prefix + tenant UUID + tenancy.database.suffix`.
You can set the suffix to `.sqlite` if you're using sqlite and want the files to be with the `.sqlite` extension. Conversely, you can leave the suffix empty if you're using MySQL, for example.
### `redis`
If `tenancy.redis.tenancy` is set to true, connections listed in `tenancy.redis.prefixed_connections` will be prefixed with `config('tenancy.redis.prefix_base') . $uuid`.
> Note: You need phpredis for multi-tenant Redis.
### `cache`
The `CacheManager` instance that's resolved when you use the `Cache` or the `cache()` helper will be replaced by `Stancl\Tenancy\CacheManager`. This class automatically uses [tags](https://laravel.com/docs/master/cache#cache-tags). The tag will look like `config('tenancy.cache.tag_base') . $uuid`.
If you need to store something in global, non-tenant cache,
### `filesystem`
> Note: It's important to differentiate(?TODO) storage_path() and the Storage facade. TODO
The `storage_path()` will be suffixed with a directory named `config('tenancy.filesystem.suffix_base') . $uuid`.
The root of each disk listed in `tenancy.filesystem.disks` will be suffixed with `config('tenancy.filesystem.suffix_base') . $uuid`.
**However, this alone would cause unwanted behavior.** It would work for S3 and similar disks, but for local disks, this would result in `/path_to_your_application/storage/app/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/`. That's not what we want. We want `/path_to_your_application/storage/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/app/`.
That's what the `root_override` section is for. `%storage_path%` gets replaced by `storage_path()` *after* tenancy has been initialized. The roots of disks listed in the `root_override` section of the config will be replaced accordingly. All other disks will be simply suffixed with `tenancy.filesystem.suffix_base` + the tenant UUID.
TODO

View file

@ -0,0 +1,53 @@
---
title: Console Commands
description: Console commands with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Console Commands {#console-commands}
The package comes with a couple of artisan commands.
## Migrate {#migrate}
The most important command. To use tenants, you have to be able to migrate their databases.
You can use the `tenants:migrate` command to migrate tenant's databases. You can also specify which tenants' databases should be migrated using the `--tenants` option.
```
php artisan tenants:migrate --tenants=8075a580-1cb8-11e9-8822-49c5d8f8ff23
```
> Note: Tenant migrations must be located in `database/migrations/tenant`.
You can use these commands outside the command line as well. If you want to migrate a tenant's database in a controller, you can use the `Artisan` facade.
```php
\Artisan::call('tenants:migrate', [
'--tenants' => [$tenant['uuid']]
]);
```
## Rollback & seed {#rollback}
- Rollback: `tenants:rollback`
- Seed: `tenants:seed`
Similarly to [migrate](#migrate), these commands accept a `--tenants` option.
## Run {#run}
You can use the tenants:run command to run your own commands for tenants.
If your command's signature were email:send {user} {--queue} {--subject} {body}, you would run this command like this:
```
php artisan tenants:run email:send --tenants=8075a580-1cb8-11e9-8822-49c5d8f8ff23 --option="queue=1" --option="subject=New Feature" --argument="body=We have launched a new feature. ..."
```
## Tenant list {#tenant-list}
```none
php artisan tenants:list
Listing all tenants.
[Tenant] uuid: dbe0b330-1a6e-11e9-b4c3-354da4b4f339 @ localhost
[Tenant] uuid: 49670df0-1a87-11e9-b7ba-cf5353777957 @ dev.localhost
```

View file

@ -0,0 +1,22 @@
---
title: Creating Tenants
description: Creating tenants with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Creating Tenants {#creating-tenants}
To create a tenant, you can use
```php
tenant()->create('tenant1.yourapp.com');
```
If you want to set some data while creating the tenant, you can pass an array with the data as the second argument:
```php
tenant()->create('tenant2.yourapp.com', [
'plan' => 'free'
]);
```

View file

@ -0,0 +1,21 @@
---
title: Custom Database Names
description: Custom Database Names with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Custom Database Names {#custom-database-names}
If you want to specify the tenant's database name, set the `tenancy.database_name_key` configuration key to the name of the key that is used to specify the database name in the tenant storage. You must use a name that you won't use for storing other data, so it's recommended to avoid names like `database` and use names like `_stancl_tenancy_database_name` instead. Then just give the key a value during the tenant creation process:
```php
>>> tenant()->create('example.com', [
'_stancl_tenancy_database_name' => 'example_com'
])
=> [
"uuid" => "49670df0-1a87-11e9-b7ba-cf5353777957",
"domain" => "example.com",
"_stancl_tenancy_database_name" => "example_com",
]
```

View file

@ -0,0 +1,18 @@
---
title: Development
description: Development | stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Development {#development}
## Running tests {#running-tests}
### With Docker {#with-docker}
If you have Docker installed, simply run ./test. When you're done testing, run docker-compose down to shut down the containers.
### Without Docker {#without-docker}
If you run the tests of this package, please make sure you don't store anything in Redis @ 127.0.0.1:6379 db#14. The contents of this database are flushed everytime the tests are run.
Some tests are run only if the CI, TRAVIS and CONTINUOUS_INTEGRATION environment variables are set to true. This is to avoid things like bloating your MySQL instance with test databases.

View file

@ -0,0 +1,9 @@
---
title: Digging Deeper
description: Digging Deeper | stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Digging Deeper {#digging-deeper}

View file

@ -0,0 +1,34 @@
---
title: Getting Started
description: Getting started with stancl/tenancy — A Laravel multi-database tenancy package that respects your code.
extends: _layouts.documentation
section: content
---
# Getting Started {#getting-started}
[**stancl/tenancy**](https://github.com/stancl/tenancy) is a Laravel multi-database tenancy package. It is designed in a way that requires you to make no changes to your codebase. Instead of applying traits on models and replacing every single reference to cache by a reference to a tenant-aware cache, the package lets you write your app without thinking about tenancy. It handles tenancy automatically.
> Note: Filesystem is the only thing that can be a little problematic. Be sure to read [that page](TODOfilesystem).
## How does it work? {#how-does-it-work}
A user visits `client1.yourapp.com`. The package identifies the tenant who this domain belongs to, and automatically does the following:
- switches database connection
- replaces the default cache manager
- switches Redis connection
- changes filesystem root paths
The benefits of this being taken care of by the package are:
- separation of concerns: you should write your app, not tenancy implementations
- reliability: you won't have to fear that you forgot to replace a reference to cache by a tenant-aware cache call. This is something you might worry about if you're implementing tenancy into an existing application.
## What is multi-tenancy? {#what-is-multi-tenancy}
Multi-tenancy is the ability to provide your application to multiple customers (who have their own users and other resources) from a single instance of your application. Think Slack, Shopify, etc.
Multi-tenancy can be single-database and multi-database.
**Single-database tenancy** means that your application uses only a single database. The way this is usually implemented is that instead of having the `id`, `title`, `user_id` and `body` columns in your `posts` table, you will also have a `tenant_id` column. This approach works until you need custom databases for your clients. It's also easy to implement, it basically boils down to having your models use a trait which adds a [global scope](https://laravel.com/docs/master/eloquent#global-scopes).
**Multi-database tenancy**, the type that this package provides, lets you use a separate database for each tenant. The benefits of this approach are scalability, compliance (some clients need to have the database on their server) and mitigation of risks such as showing the wrong tenant's data to a user. The downside is that this model is harder to implement, which is why this package exists.

8
source/docs/index.html Normal file
View file

@ -0,0 +1,8 @@
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=/docs/getting-started">
<title>stancl/tenancy</title>
</head>
</html>

View file

@ -0,0 +1,65 @@
---
title: Installation
description: Installing stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Installation {#getting-started}
Laravel 5.8 or higher is needed.
### Require the package via composer
First you need to require the package using composer:
```
composer require stancl/tenancy
```
### Automatic installation {#automatic-installation}
To install the package, simply run
```
php artisan tenancy:install
```
You will be asked if you want to store your data in Redis or a relational database. You can read more about this on the [Storage Drivers](storage-drivers) page.
This will do all the steps listed in the [Manual installation](#manual-installation) section for you.
### Manual installation {#manual-installation}
If you prefer installing the package manually, you can do that too. It shouldn't take more than a minute either way.
#### Setting up middleware
Now open `app/Http/Kernel.php` and make the `InitializeTenancy` middleware top priority, so that it gets executed before anything else, making sure things like the database switch connections soon enough:
```php
protected $middlewarePriority = [
\Stancl\Tenancy\Middleware\InitializeTenancy::class,
// ...
];
```
#### Creating routes
The package lets you have tenant routes and "exempt" routes. Tenant routes are your application's routes. Exempt routes are routes exempt from tenancy — landing pages, sign up forms, and routes for managing tenants.
Routes in `routes/web.php` are exempt, whereas routes in `routes/tenant.php` have the `InitializeTenancy` middleware automatically applied on them.
So, to create tenant routes, put those routes in a new file called `routes/tenant.php`.
#### Configuration
Run the following:
```
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=config
```
This creates a `config/tenancy.php`. You can use it to configure how the package works.
Configuration is explained in detail on the [configuration](configuration) page.

View file

@ -0,0 +1,20 @@
---
title: Middleware Configuration
description: Middleware Configuration with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Middleware Configuration {#middleware-configuration}
When a tenant route is visited and the tenant can't be identified, an exception is thrown. If you want to change this behavior, to a redirect for example, add this to your `app/Providers/AppServiceProvider.php`'s `boot()` method:
```php
// use Stancl\Tenancy\Middleware\InitializeTenancy;
$this->app->bind(InitializeTenancy::class, function ($app) {
return new InitializeTenancy(function ($exception) {
// return redirect()->route('foo');
});
});
```

View file

@ -0,0 +1,17 @@
---
title: Stay Updated
description: Stay Updated | stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Stay Updated {#stay-updated}
If you'd like to be notified about new versions, you can [sign up for e-mail notifications](https://stancl.github.io/tenancy/#stay-updated) or join our [Telegram channel](https://t.me/joinchat/AAAAAFjdrbSJg0ZCHTzxLA).
You can choose whether you want to receive emails about major versions and/or minor versions.
- Major versions include breaking changes. Composer won't know about these versions and won't update to them. Major versions will be released about once every 6 months.
- Minor versions include backwards-compatible features and bug fixes.
<!-- todo mailchimp dialog -->

View file

@ -0,0 +1,50 @@
---
title: Storage Drivers
description: Storage Drivers of stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Storage Drivers {#storage-drivers}
Storage drivers are used to store a list of all tenants, their domains and any extra information you store about your tenants (e.g. their plan).
Currently, database and Redis storage drivers are available as part of the package. However, you can [write your own](writing-storage-drivers) (and contribute ❤️) storage drivers.
## Database {#database}
The database storage driver lets you store tenant information in a relational database like MySQL, PostgreSQL and SQLite.
The benefit of this storage driver is that you don't have ot use both Redis and a database for your data. Also you don't have to do as much configuration.
To use this driver, you need to have a `tenants` table in the database associated with the `central` connection. So copy your currenty used connection (`mysql`, `sqlite`, ...) and add it to `database.connections` under the name `central`.
To create the `tenants` table, you can use the migration that comes with this package. If you haven't published it during the installation, publish it now:
```
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
```
By default, all of your data will be stored in the JSON column `data`. If you want to store some data in a dedicated column (to leverage indexing, for example), add the column to the migration and to `tenancy.custom_columns` config.
## Redis {#redis}
The Redis storage driver lets you store tenant information in Redis, a high-performance key-value store.
The benefit of this storage driver is its performance.
**Note that you need to configure persistence on your Redis instance if you don't want to lose all information about tenants.**
Read the [Redis documentation page on persistence](https://redis.io/topics/persistence). You should definitely use AOF and if you want to be even more protected from data loss, you can use RDB **in conjunction with AOF**.
If your cache driver is Redis and you don't want to use AOF with it, run two Redis instances. Otherwise, just make sure you use a different database (number) for tenancy and for anything else.
To use this driver, create a new Redis connection in the `database.redis` configuration called `tenancy`.
```php
'tenancy' => [
'host' => env('TENANCY_REDIS_HOST', '127.0.0.1'),
'password' => env('TENANCY_REDIS_PASSWORD', null),
'port' => env('TENANCY_REDIS_PORT', 6380), // different port = separate Redis instance
'database' => env('TENANCY_REDIS_DB', 3), // alternatively, different database number
],
```

View file

@ -0,0 +1,28 @@
---
title: Tenant Routes
description: Tenant routes with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Tenant Routes {#tenant-routes}
Routes within `routes/tenant.php` will have the `web` middleware group and the `IntializeTenancy` middleware automatically applied on them. This middleware attempts to identify the tenant based on the current hostname. Once the tenant is identified, the database connection, cache, filesystem root paths and, optionally, Redis connection, will be switched.
Just like `routes/web.php`, these routes use the `App\Http\Controllers` namespace.
> If a tenant cannot be identified, anexception will be thrown. If you want to change this behavior (to a redirect, for example) read the [Middleware Configuration](middleware-configuration) page.
## Exempt routes {#exempt-routes}
Routes outside the `routes/tenant.php` file will not have the tenancy middleware automatically applied on them. You can apply this middleware manually, though.
If you want some of your, say, API routes to be multi-tenant, simply wrap them in a Route group with this middleware:
```php
use Stancl\Tenancy\Middleware\InitializeTenancy;
Route::middleware(InitializeTenancy::class)->group(function () {
// Route::get('/', 'HelloWorld');
});
```

View file

@ -0,0 +1,48 @@
---
title: Tenant Storage
description: Tenant storage with stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Tenant Storage {#tenant-storage}
Tenant storage is where tenants' uuids and domains are stored. You can store things like the tenant's plan, subscription information, and tenant-specific application configuration in tenant storage. You can use these functions:
```php
get (string|array $key, string $uuid = null) // $uuid defaults to the current tenant's UUID
put (string|array $key, mixed $value = null, string $uuid = null) // if $key is array, make sure $value is null
```
To put something into the tenant storage, you can use `put()` or `set()`.
```php
tenancy()->put($key, $value);
tenancy()->set($key, $value); // alias for put()
tenancy()->put($key, $value, $uuid);
tenancy()->put(['key1' => 'value1', 'key2' => 'value2']);
tenancy()->put(['key1' => 'value1', 'key2' => 'value2'], null, $uuid);
```
To get something from the storage, you can use `get()`:
```php
tenancy()->get($key);
tenancy()->get($key, $uuid);
tenancy()->get(['key1', 'key2']);
```
> Note: `tenancy()->get(['key1', 'key2'])` returns an array with values only
Note that $key has to be a string or an array with string keys. The value(s) can be of any data type. Example with arrays:
```php
>>> tenant()->put('foo', ['a' => 'b', 'c' => 'd']);
=> [ // put() returns the supplied value(s)
"a" => "b",
"c" => "d",
]
>>> tenant()->get('foo');
=> [
"a" => "b",
"c" => "d",
]
```

20
source/docs/usage.md Normal file
View file

@ -0,0 +1,20 @@
---
title: Usage
description: Usage | stancl/tenancy — A Laravel multi-database tenancy package that respects your code..
extends: _layouts.documentation
section: content
---
# Usage {#usage}
This chapter describes usage of the package. That includes creating tenants, deleting tenants, storing data in the tenant storage.
Most pages will use the `tenancy()` helper function. This package comes with two helpers - `tenancy()` and `tenant()`. They do the same thing, so you can use the one that reads better given its context.
`tenant()->create()` reads better than `tenancy()->create()`, but `tenancy()->init()` reads better than `tenant()->init()`.
You can pass an argument to the helper function to get a value out of the tenant storage. `tenant('plan')` is identical to [`tenant()->get('plan')`](tenant-storage).
The package also comes with two facades. `Tenancy` and `Tenant`. Use what feels the best.
Both the helpers and the facades resolve the `TenantManager` from the service container.

BIN
source/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

8
source/index.html Normal file
View file

@ -0,0 +1,8 @@
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=https://stancl.github.io/tenancy">
<title>stancl/tenancy</title>
</head>
</html>