---
title: 'User Multi-Tenancy and Observers'
url: 'https://graker.ru/news/2018/08/13/user-multi-tenancy-and-observers'
language: ru
type: post
author: 'Роман Грачев'
published: '2018-08-13T10:30:00+03:00'
updated: '2018-08-13T10:33:48+03:00'
categories:
  - Laravel
  - Программирование
---

# User Multi-Tenancy and Observers

> First, I want to admit that there are a lot of ways to implement or even think about multi-tenancy. For more thoughts on this, I recommend a wonderful presentation called Multi-Tenant Laravel by Tom Schlick. In this article, I will show multi-tenancy based on single database and Laravel Global Scopes.
> 
> Now, let’s add multi-tenancy to our database entries. Let’s imagine we have DB table called posts, and we want each user to see only their own posts.
> 
> **[Use Laravel Observers and Global Scopes to Create User Multi-Tenancy](https://laraveldaily.com/use-laravel-observers-and-global-scopes-to-create-user-multi-tenancy/)**

Через один observer куда элегантнее, чем пихать сохраненение user id (или другой сущности-владельца!) в каждый контроллер.
