Windows install wsl and set default wsl 2

Step 1:
Open the below link and READ IT!

https://learn.microsoft.com/en-za/windows/wsl/install

1: Open PowerShell and Start the install process
wsl --install

2: Result shows you available distros: 
Ubuntu             Ubuntu
Debian             Debian GNU/Linux
kali-linux         Kali Linux Rolling
SLES-12            SUSE Linux Enterprise Server v12
SLES-15            SUSE Linux Enterprise Server v15
Ubuntu-18.04       Ubuntu 18.04 LTS
Ubuntu-20.04       Ubuntu 20.04 LTS
OracleLinux_8_5    Oracle Linux 8.5
OracleLinux_7_9    Oracle Linux 7.9

3: Install your selected distro. In my case I am choosing Ubuntu.
wsl --install Ubuntu

4: Wait for the install to finish.
Enter username and password in the ubuntu termainal and proceed.

5: Switch back to PowerShell and Check that your wsl version. 
wsl -l -v

6: Run the below command.
sudo apt update && sudo apt upgrade

7: Set default wsl version to version 2
wsl --set-default-version 2

8: If you manually installed WSL prior to the wsl --install command being available, you may also need to enable the virtual machine optional component used by WSL 2 and install the kernel package if you haven't already done so.
--
https://learn.microsoft.com/en-za/windows/wsl/install-manual#step-3---enable-virtual-machine-feature

Flutter Add Camera Permission Request for IOS

Find the info.plist file
And add the following :

<key>NSPhotoLibraryUsageDescription</key>
<string>App needs access to photo lib for profile images</string>

<key>NSCameraUsageDescription</key>
<string>To capture profile photo please grant camera access</string>

Metabox – Starter Profile Form

############################################################################
// Registration Form Custom Fields Configured Here
add_filter( 'rwmb_meta_boxes', 'registration' );
function registration( $meta_boxes ) {
    $meta_boxes[] = [
        'title'  => 'Registration',
        'id'     => 'registration',
        'type'   => 'user',
        'fields' => [],
    ];
    return $meta_boxes;
}
############################################################################
function register_user_profile_fields($meta_boxes) {
    $prefix = 'user_profile_';
    // fields
    $meta_boxes[] = [
        'id'     => $prefix . 'edit_form_basic',
        'title'  => 'Your basic information',
        'type'   => 'user',
        'fields' => [
            [
                'id'   => 'first_name', // THIS
                'name' => 'First Name',
                'type' => 'text',
            ],
            [
                'id'   => 'last_name', // THIS
                'name' => 'Last Name',
                'type' => 'text',
            ],
            [
              'id'       => 'user_email',
              'type'     => 'email',
              'name'     => 'Email address',
              'readonly' => ( wp_get_current_user()->user_email ) ? true : false,
              'required' => true
            ],
            [
              'name' => 'Country Code',
              'id'   => 'mobile_country_code',
              'type' => 'text',
              'required' => true,
            ],
            [
              'name' => 'Contact Number',
              'id'   => 'user_mobile',
              'type' => 'tel',
              'required' => true,
            ],
            [
              'name' => 'Title (Job Role/Position)',
              'id'   => 'user_job_title',
              'type' => 'text',
            ],
        ],
      ];
    return $meta_boxes;
}
add_action( 'rwmb_meta_boxes', 'register_user_profile_fields',2, 1);
############################################################################
//////////////////////////////////////
//  [shortcode_avatar]  //
//////////////////////////////////////
function shortcode_avatar(){
    ob_start();
    include 'avatar.php';
    return ob_get_clean();
}
add_shortcode( 'shortcode_avatar', 'shortcode_avatar');
############################################################################

Vue / Axios Post

axios.post('/your-url-or-api-destination', payload)
.then((response) => {
  // Show Success Message
  this.$bvToast.toast('Terms and Conditions Saved', {
    title: 'Success',
    variant: 'success',
    solid: true
  });
})
.catch((error) => {
  // Show Error Message
  this.$bvToast.toast('Terms and Conditions Not Saved', {
    title: 'Error',
    variant: 'danger',
    solid: true
  });
});

Laravel Class Construct

class MyCustomClassName
{

    public function __construct()
    {
    }

    public function whatever_whatever(){
      // Code goes here. And can use anything from the construct. The construct will always load first
    }

}

Why we have classes and controllers in MVC?

A Controller or Class in MVC are both just classes.
So... Technically speaking.
It is possible to write all your functionality inside your controllers and completely ditch the classes folder.
But! The purpose of breaking out into separate classes is re-usability.

Controllers :

<?php

namespace App\Http\Controllers;

class MyCustomController extends Controller
{

}

Classes :

<?php

namespace App\Classes\MyCustomClass;

class ClassNameWhateverWhatever
{

}

Why Classes, what is the point?
-----------------------------------------------------------------
Classes serve as containers for specific purposes.
For example.

You create a class for :
Car
--
And inside your class you write all your functionality.
A car can have specific functionality.
--
moveForward()
reverse()
brake()
switchOnLights()

-----------------------------------------------------------------
Then, you reference your car class inside your contollers.
--
So something like
car->moveForward();

This design strategy makes your code extremely easy to re-use without having to re-write additional functionality. This is why we seperate everything into a class and then we create another class called a controller class and reference our classes inside the controller classes.

Laravel Save Function, update and add with exceptions

Save Function (Update and Add in 1 function based on ID)

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class RandomController extends WhateverWhateverController {

    public function saveTermsAndConditions(Request $request){
        if (isset($request->id)) {
            // Update
            try {
                DB::table('table_name')->where('id',$request->id)->update(
                    array(
                        'field'=>$request->field,
                        'content'=>$request->content,
                        'updated_at' => date("Y-m-d H:i:s", strtotime('now')),
                    )
                );
                $termsAndConditions = DB::table('table_name')->where('id', $request->id)->first();
            } catch (\Exception $e) {
                return response()->json($e);
            }
        } else {
            // Add
            try {
                $id = DB::table('table_name')->insertGetId(
                    array(
                        'field' => $request->field, 
                        'content' => $request->content, 
                        'created_at' => date("Y-m-d H:i:s", strtotime('now')),
                        'updated_at' => date("Y-m-d H:i:s", strtotime('now'))
                    )
                );
                $termsAndConditions = DB::table('table_name')->where('id', $id)->first();
            } catch (\Exception $e) {
                return response()->json($e);
            }
        }

        return $termsAndConditions;
    }
}