Skip to content

Instantly share code, notes, and snippets.

View himan72's full-sized avatar

Mohammed Hicham himan72

View GitHub Profile
@stefanbauer
stefanbauer / fix_mysql_big_sur.sh
Created August 14, 2020 11:29
Fix MySQL 5.7 ERROR 1524 (HY000): Plugin ‘auth_socket’ is not loaded in macOS Big Sur
# If you don't use brew services, install it
# https://github.com/Homebrew/homebrew-services
# Stop MySQL
brew services stop mysql@5.7
# Start MySQL in safe mode
mysqld_safe --skip-grant-tables &
# Login to MySQL
@vicgonvt
vicgonvt / deployment_guide.md
Last active March 17, 2024 06:51
Deployment Guide for Ubuntu Server from Scratch with Laravel
@iben12
iben12 / 1_Laravel_state-machine.md
Last active August 12, 2023 08:36
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.