Monday, 20 March 2017

Resolve the issue with laravel session permission denied issue on Mac

Please follow the steps below.

1. Go to your project root folder via Finder where you keep all your projects and right click on it.

2. Then, click on "Get Info" and you will see the pop-up window.

3. At bottom-right of the window, there is 'Lock' icon, click on it to Unlock it.

4. Next, select the 'Read and Write' (if it was readonly) privilege for 'staff' name.

5. Afterwards, keep select the 'staff' name, then click to 'Setting' icon next to +/- signs, and select 'Apply to enclosed items...'.

6. Finally, click the 'Lock' icon to make it locked once you completed above steps

Then, your project file has full permission for Read/write and you don't need to `chmod 777` all time.

Username validation using Regis on Laravel

Please find the validation script below to fix the username validation allowing it to have only Alphanumeric with dot (.), dash/hypen (-) and underscore(_).

$validator = Validator::make($request->all(),
            ['user_name' =>
                ['required', 'min:4', 'max:20', 'unique:auth_users', 'Regex:/^[a-zA-Z0-9-._]+$/']