use s3 storage laravel

use s3 storage laravel

return Storage::disk(‘s3’)->response(‘images/’ . $image->filename); Here is what the above code is Doing: 1. We’re using the Storage facade to access the s3 disk. 2. We’re using the response method to generate a response that will be sent back to the browser. 3. We’re passing the path to the image as the first argument to the…

Snackbar – NOTIFICATIONS INSPIRED BY GOOGLE MATERIAL DESIGN

Snackbar – NOTIFICATIONS INSPIRED BY GOOGLE MATERIAL DESIGN

Snackbar.show({pos: ‘bottom-left’}); //Set the position Here is what the above code is Doing: 1. We are creating a new variable called ‘snackbar’ and setting it equal to a new Snackbar object. 2. We are setting the text of the snackbar to ‘Hello World’. 3. We are setting the duration of the snackbar to 4000 milliseconds….

laravel observer check if field changed

laravel observer check if field changed

class UserObserver { /** * Listen to the User created event. * * @param \App\User $user * @return void */ public function updating(User $user) { if($user->isDirty(’email’)){ // email has changed $new_email = $user->email; $old_email = $user->getOriginal(’email’); } } } Here is what the above code is Doing: 1. We are listening to the User model’s…

mongoose get elements that contain substring

mongoose get elements that contain substring

Books.find( { “authors”: { “$regex”: “Alex”, “$options”: “i” } }, function(err,docs) { } ); Here is what the above code is Doing: 1. We’re using the find() method to search for all documents in the books collection. 2. We’re using the $regex operator to find all documents where the authors field contains the string “Alex”….

Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, bool given in C:\newxammp\htdocs\learn\index.php on line 11

Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, bool given in C:\newxammp\htdocs\learn\index.php on line 11

#where you are running mysqli_query , add ‘or die( mysqli_error($db)’ #e.g $sql = “SELECT * FROM users”; $result = mysqli_query($db, $sql) or die( mysqli_error($db)); #$db being the variable holding the connection to db Here is what the above code is Doing: 1. It’s creating a variable called $sql that holds the SQL query. 2. It’s…

angular input date pattern validation

angular input date pattern validation

(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31)) Here is what the above code is Doing: 1. The first part of the code, (?:19|20)[0-9]{2} is matching the year. 2. The next part, (?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31)) is matching the month and the day. 3. The first part of the second part, (?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]) is matching the month and the day for months that have 30 or…

how to get powers

how to get powers

how to get powers Here is what the above code is Doing: 1. We’re creating a class called “Superhero” 2. We’re creating a function called “__init__” that will run every time we create a new instance of the class. 3. We’re creating a variable called “name” that will be equal to whatever we pass in…