For my Laravel App, I need two types of Users: Staff & Member. Some Staff-User has an "is_admin" flag for more rights.
My first attempt was to create two new User-like Models. But as I found out, and it was recommended to me, that is not the common way.
So now I use the User-Model only for the Login (email, name, password & role) and to divide the User-Types by a role field.
That worked very well for the login procedure.
But if it's necessary to edit some fields of one of the User-Type, it is getting complicated, because there are always two Models to handle.
This is my code to create a new Member, for example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shows all font and background colors on an table, | |
// use with Greasemonkes or as a browser bookmark | |
(function () { | |
'use strict'; | |
function categorizeAndRankColorsWithRanksOnWebsite() { | |
// let allElements = document.getElementsByTagName('*'); | |
const allElements = Array.from(document.body.getElementsByTagName('*')).filter((element) => element.tagName !== 'STYLE' && element.tagName !== 'SCRIPT'); | |
// console.log('allElements', allElements); | |
const colorCategories = { |
No Javascript required. Just plain CSS.
A Pen by Yago Estévez on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return *positive* remainder of n divided by m. | |
export function mod(n, m) { | |
return ((n % m) + m) % m; | |
} | |
export function sleep(time) { | |
return new Promise((res) => setTimeout(res, time)); | |
} | |
function randInt(a, b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let color = 'color: LimeGreen;'; | |
let ms = performance.now(); | |
async function doAPromise(success, timeout) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
if (success) { | |
resolve(); | |
console.log('%cPromise resolved', color, ms); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import { Writable } from 'svelte/store' | |
import { writable as internal, get } from 'svelte/store' | |
import { PUBLIC_LOCALSTORAGE_PREFIX as PRFX } from '$env/static/public'; | |
declare type Updater<T> = (value: T) => T | |
declare type StoreDict<T> = { [key: string]: Writable<T> } | |
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
const stores: StoreDict<any> = {} |
NewerOlder