many to many
relationship user_id
inside user_roles
table must be exactly the same as the id
field inside users
table
Example: if users->id
is bigint(20) unsigned
then user_role->user_id
must be exactly bigint(20) unsigned
123
will be encrypted and then decrypted back with AES-128-ECB
encryption algorithm.
Encrypts the text using the secret key sec key
function encrypt_text($text, $secret_key)
{
return openssl_encrypt($text,"AES-128-ECB", $secret_key);
}
Decrypts encrypted text (first parameter) using the secret key (second parameter)function decrypt_text($encrypted_string, $secret_key)
{
return openssl_decrypt($encrypted_string,"AES-128-ECB", $secret_key);
}
Calls the above two functions to perform encryption and decryption// Secret key, that is used to encrypt and decrypt the $text
content
$secret = 'sec key';
// the text that we want to encryption and decryption
$text = '123';
$password_encrypted = encrypt_text($text, $secret);
$password_decrypted = decrypt_text($password_encrypted, $secret);
echo 'Encrypted text: ' . $password_encrypted . '<br>';
echo 'Decrypted password: ' . $password_decrypted;
php artisan make:model Asset -m -c -r
Long version of the above command would be:php artisan make:model Asset --migration --controller --resource
var counter = 10;
var counter;
console.log(counter); // 10
However, if we redeclare a variable with the let keyword, we will get an error:
let counter = 10;
let counter; // undefined
var counter = 0;
console.log(window.counter); // 0
However, the let variables are not added to the global object:
let counter = 0;
console.log(window.counter); // undefined
for (let i = 0; i < 5; i++) {
console.log(`Inside the loop: ${i}`);
}
console.log(`Outside the loop: ${i}`);
output:
Inside the loop: 0
Inside the loop: 1
Inside the loop: 2
Inside the loop: 3
Inside the loop: 4
and will be error:
Uncaught ReferenceError: i is not defined
because t the variable 'i' only exists and can be accessible inside the for loop block.for (var i = 0; i < 5; i++) {
console.log(`Inside the loop: ${i}`);
}
console.log(`Outside the loop: ${i}`);
output:
Inside the loop: 0
Inside the loop: 1
Inside the loop: 2
Inside the loop: 3
Inside the loop: 4
Outside the loop: 5
In this example, the i
variable is a global variable. Therefore, it can be accessed from both inside and after the for loop.function increase() {
var counter = 10;
}
// cannot access the counter variable here
In this example, the counter
variable is local to the increase() function. It cannot be accessible outside of the function.var person1 = {
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
var person2 = {
firstName:"John",
lastName: "Doe",
}
person1.fullName.call(person2); // Will return "John Doe"
person1.fullName.apply(person2); // Will return "John Doe"
var person = {
firstName : "John",
lastName : "Doe",
id : 5566,
myFunction : function() {
return this; // [object Object]
return this.firstName + " " + this.lastName; // John Doe
}
};