How to setup mailtrap in laravel.

Everyone who is developing an application needs to test it with emails. These emails which we test can be a real heactic task if we use the real email ids. we will have to create or ask different persons for their emails and work on it. This is a real heactic task.

To sort out this problem there a great solution that we can use. its Mailtrap.io

What is Mailtrap?

Mailtrap is a fake SMTP server to test, view and share emails sent from the development and staging environments. Mailtrap provides dummy email veryfications once we have set it up for the application. All emails sent to Mailtrap are held in the Mailtrap inbox.

How to setup Mailtrap.

There is very simple steps to set it up. we just need to follow the following steps.

  1. We first have to create an account, for this we need to visit https://mailtrap.io we will see an interface as
mailtrap signup
  1. Then we need to click on signup button to signup either through your Google account, GitHub account or by providing your email address and password. we will see interface as
mailtrap signup with account
  1. Soon after the signup we will see interface like thatNow we are ready to go.

Tagged : / / / / /

How to fix PHP fatal error in Laravel? Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)

Whenever we type the below displayed command

locobucci error

We see the command runs initially good but there comes some problem in few moments. similar to

php fatal error

This error is PHP fatal error: and complete display image is

fatal error complete image

What we need to do to remove this ?

Folllow the below steps:

  1. Close the xampp if its running.
  2. got to “C:\ProgramData\ComposerSetup\bin” (we can copy the location and paste it in the explorer header)
explorer heading

just press on the above header (after pc) and paste the location and press enter

composer setup/bin location

This will open the file location:

3. We then need to open the composer.bat to edit it (right click on it and click on edit with notepad++)

4. Now just copy the below code and replace it with the code present in composer.bat

Code:

@echo OFF
:: in case DelayedExpansion is on and a path contains ! 
setlocal DISABLEDELAYEDEXPANSION
php -d memory_limit=-1 "%~dp0composer.phar" %*

5. Now save it. For saving it

  • Press (Ctrl + S)
  • we will be prompted as run as Administrator.
  • press Allow
  • Then again Press ( Ctrl + S)
  • The file will be saved.

Now we can run the above command and check it.

we will see the command execuites sucessfully

Happy Coding!

Tagged : / / / / / / /

How to fix oauth private key does not exist problem in Laravel?

If we get error as Auth private key does not exist on the browser when we run any laravel project .

Something similar to

privet auth key not found

Then we just need to install the passport and do the changes to the places where needed.

Command to install Passport:

php artisan passport:install

Soon after the passport is install we will get the following things:

  1. Client id
  2. Client secret
client id and client secret

We need to put client id in the in env files where required.

Somewhat similar to given below:

placing client id and secret

We need to change the client id and client secret to all the places where the concern configuration are used.

Few important links for reference :

  1. Setup laravel project and understand folder structure click here.
  2. Crud operation and detailed explaination. click here.

Tagged : / / / /

How to fix vendor directory not present ?

whenever we run the artisan command to migrate the control looks for the vendor directory and some files inside it. thus if the vendor directory is not present, the command will not get execuited and we will get error.

The error which we see looks like :-

vendor directory not present

To overcome this error we need to update the composer thus we need to write

composer update 

This would download and update the composer and all the packages and files inside it.

The updated pages will look like:

The complete packages which will be downloaded and updated are listed below.

PS C:\xampp\htdocs\mhn-doctors-ms> composer update 
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 96 installs, 0 updates, 0 removals
  - Installing kylekatarnls/update-helper (1.2.1): Loading from cache
  - Installing symfony/thanks (v1.2.10): Loading from cache
  - Installing symfony/finder (v3.4.47): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing symfony/debug (v3.4.47): Loading from cache
  - Installing symfony/polyfill-ctype (v1.22.1): Loading from cache
  - Installing vlucas/phpdotenv (v2.6.7): Loading from cache
  - Installing symfony/css-selector (v5.2.4): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.22.1): Loading from cache
  - Installing symfony/var-dumper (v3.4.47): Loading from cache
  - Installing symfony/routing (v3.4.47): Loading from cache
  - Installing symfony/process (v3.4.47): Loading from cache
  - Installing symfony/polyfill-php72 (v1.22.1): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.22.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.22.1): Loading from cache
  - Installing symfony/polyfill-php70 (v1.20.0)
  - Installing paragonie/random_compat (v2.0.19): Loading from cache
  - Installing symfony/http-foundation (v3.4.47): Loading from cache
  - Installing symfony/event-dispatcher-contracts (v1.1.9): Loading from cache
  - Installing psr/container (1.1.1): Loading from cache
  - Installing symfony/event-dispatcher (v4.4.20): Loading from cache
  - Installing symfony/polyfill-php56 (v1.20.0)
  - Installing symfony/http-kernel (v3.4.47): Loading from cache
  - Installing symfony/console (v3.4.47): Loading from cache
  - Installing symfony/polyfill-iconv (v1.22.1): Loading from cache
  - Installing doctrine/lexer (1.2.1): Loading from cache
  - Installing egulias/email-validator (3.1.1): Downloading (100%)
  - Installing swiftmailer/swiftmailer (v6.2.7): Loading from cache
  - Installing ramsey/uuid (3.9.3): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing symfony/translation-contracts (v1.1.10): Loading from cache
  - Installing symfony/translation (v4.3.11): Loading from cache
  - Installing nesbot/carbon (1.39.1): Loading from cache
  - Installing mtdowling/cron-expression (v1.2.3): Loading from cache
  - Installing monolog/monolog (1.26.0): Loading from cache
  - Installing league/mime-type-detection (1.7.0): Loading from cache
  - Installing league/flysystem (1.1.3): Loading from cache
  - Installing erusev/parsedown (1.7.4): Loading from cache
  - Installing doctrine/inflector (1.4.3): Loading from cache
  - Installing laravel/framework (v5.5.50): Loading from cache
  - Installing maximebf/debugbar (v1.16.5): Loading from cache
  - Installing barryvdh/laravel-debugbar (v3.4.2): Loading from cache
  - Installing fideloper/proxy (3.3.4): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing zendframework/zend-diactoros (1.8.7): Loading from cache
  - Installing symfony/psr-http-message-bridge (v1.2.0): Loading from cache
  - Installing phpseclib/phpseclib (2.0.31): Downloading (100%)
  - Installing defuse/php-encryption (v2.3.1): Downloading (100%)
  - Installing lcobucci/jwt (3.4.5): Loading from cache
  - Installing league/event (2.2.0): Loading from cache
  - Installing league/oauth2-server (6.1.1): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing guzzlehttp/psr7 (1.8.1): Loading from cache
  - Installing guzzlehttp/promises (1.4.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.5.5): Loading from cache
  - Installing firebase/php-jwt (v5.2.1): Loading from cache
  - Installing laravel/passport (v4.0.3): Loading from cache
  - Installing jakub-onderka/php-console-color (v0.2): Loading from cache
  - Installing jakub-onderka/php-console-highlighter (v0.4): Loading from cache
  - Installing nikic/php-parser (v4.10.4): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache
  - Installing psy/psysh (v0.9.12): Loading from cache
  - Installing laravel/tinker (v1.0.10): Loading from cache
  - Installing filp/whoops (2.12.0): Downloading (100%)
  - Installing fzaninotto/faker (v1.9.2): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.1): Loading from cache
  - Installing mockery/mockery (1.3.4): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (1.0.0): Loading from cache
  - Installing sebastian/recursion-context (3.0.1): Loading from cache
  - Installing sebastian/object-reflector (1.1.2): Loading from cache
  - Installing sebastian/object-enumerator (3.0.4): Loading from cache
  - Installing sebastian/global-state (2.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.3): Loading from cache
  - Installing sebastian/environment (3.1.0): Loading from cache
  - Installing sebastian/diff (2.0.1): Loading from cache
  - Installing sebastian/comparator (2.1.3): Loading from cache
  - Installing doctrine/instantiator (1.4.0): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/phpunit-mock-objects (5.0.10): Loading from cache
  - Installing phpunit/php-timer (1.0.9): Loading from cache
  - Installing phpunit/php-file-iterator (1.4.5): Loading from cache
  - Installing theseer/tokenizer (1.2.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.2): Loading from cache
  - Installing phpunit/php-token-stream (2.0.2): Loading from cache
  - Installing phpunit/php-code-coverage (5.3.2): Loading from cache
  - Installing webmozart/assert (1.10.0): Loading from cache
  - Installing phpdocumentor/reflection-common (2.2.0): Loading from cache
  - Installing phpdocumentor/type-resolver (1.4.0): Loading from cache
  - Installing phpdocumentor/reflection-docblock (5.2.2): Loading from cache
  - Installing phpspec/prophecy (v1.10.3): Loading from cache
  - Installing phar-io/version (1.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.1): Loading from cache
  - Installing myclabs/deep-copy (1.10.2): Loading from cache
  - Installing phpunit/phpunit (6.5.14): Loading from cache
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/var-dumper suggests installing ext-symfony_debug
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) 
symfony/event-dispatcher-contracts suggests installing psr/event-dispatcher
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/console suggests installing symfony/lock
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
swiftmailer/swiftmailer suggests installing ext-intl (Needed to support internationalized email addresses)
ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)        
ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing paragonie/random-lib (Provides RandomLib for use with the RandomLibAdapter)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)        
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)       
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laravel/framework suggests installing ext-pcntl (Required to use all features of the queue worker.)
laravel/framework suggests installing ext-posix (Required to use all features of the queue worker.)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (~3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.5).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use Flysystem caching (~1.0).)
laravel/framework suggests installing nexmo/client (Required to use the Nexmo transport (~1.0).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (~3.0).)
laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (~1.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (~3.0).)
laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (~3.3).)   
maximebf/debugbar suggests installing kriswallsmith/assetic (The best way to manage assets)
maximebf/debugbar suggests installing predis/predis (Redis storage)
symfony/psr-http-message-bridge suggests installing nyholm/psr7 (For a super lightweight PSR-7/17 implementation)
phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.)
phpseclib/phpseclib suggests installing ext-mcrypt (Install the Mcrypt extension in order to speed up a few other cryptographic operations.)
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
lcobucci/jwt suggests installing lcobucci/clock (*)
guzzlehttp/psr7 suggests installing laminas/laminas-httphandlerrunner (Emit PSR-7 responses)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-posix (If you have PCNTL, you'll want the POSIX extension as well.)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already 
support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.   
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run ".\vendor\bin\upgrade-carbon" to get help in updating carbon and other frameworks and libraries that depend on it.  
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Package manifest generated successfully.
42 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Tagged : / / / /

Built-in/Predefined Methods in JavaScript

In JavaScript, however, a method is a function that belongs to an object. A JavaScript method is a property containing a function definition.

There is a long list of Built-in or pre-defined methods in JavaScript

Maths Methods in JavaScript

  • min() ->Returns the smallest of zero or more numbers.
  • pow() ->Returns base to the exponent power, that is, base exponent.
  • abs() ->Returns the absolute value of a number.
  • acos() ->Returns the arccosine (in radians) of a number.
  • asin() ->Returns the arcsine (in radians) of a number.
  • sin() ->Returns the sine of a number.
  • sqrt() ->Returns the square root of a number.
  • tan() ->Returns the tangent of a number.
  • atan() ->Returns the arctangent (in radians) of a number.
  • atan2() ->Returns the arctangent of the quotient of its arguments.
  • exp() ->Returns EN, where N is the argument, and E is Euler’s constant, the base of the natural logarithm.
  • floor() ->Returns the largest integer less than or equal to a number.
  • log() ->Returns the natural logarithm (base E) of a number.
  • max() ->Returns the largest of zero or more numbers.
  • ceil() ->Returns the smallest integer greater than or equal to a number.
  • cos() ->Returns the cosine of a number.
  • random() ->Returns a pseudo-random number between 0 and 1.
  • round() ->Returns the value of a number rounded to the nearest integer.
  • toSource() ->Returns the string “Math”.

Boolean Methods in JavaScript

  • toString() ->Returns a string of either “true” or “false” depending upon the value of the object.
  • toSource() ->Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
  • valueOf() ->Returns the primitive value of the Boolean object.

String Methods in JavaScript

  • length() ->Returns the length of the string.
  • search() ->Executes the search for a match between a regular expression and a specified string.
  • split() ->Splits a String object into an array of strings by separating the string into substrings.
  • lastIndexOf() ->Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
  • charAt() ->Returns the character at the specified index.
  • match() ->Used to match a regular expression against a string.
  • charCodeAt() ->Returns a number indicating the Unicode value of the character at the given index.
  • concat()-Combines the text of two strings and returns a new string.
  • replace() ->Used to find a match between a regular expression and a string and to replace the matched substring with a new substring.
  • substr() ->Returns the characters in a string beginning at the specified location through the specified number of characters.
  • toLowerCase() ->Returns the calling string value converted to lower case.
  • toString() ->Returns a string representing the specified object.
  • toUpperCase() ->Returns the calling string value converted to uppercase.
  • valueOf() ->Returns the primitive value of the specified object.
  • toLocaleLowerCase() ->The characters within a string are converted to lower case while respecting the current locale.
  • toLocaleUpperCase() ->The characters within a string are converted to the upper case while respecting the current locale.
  • substring() ->Returns the characters in a string between two indexes into the string.

Array Methods in JavaScript

  • every() ->Returns true if every element in this array satisfies the provided testing function.
  • reduce() ->Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
  • filter() ->Creates a new array with all of the elements of this array for which the provided filtering function returns true.
  • forEach() ->Calls a function for each element in the array.
  • indexOf() ->Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
  • join() ->Joins all elements of an array into a string.
  • slice() ->Extracts a section of an array and returns a new array.
  • some() ->Returns true if at least one element in this array satisfies the provided testing function.
  • toSource() ->Represents the source code of an object
  • lastIndexOf() ->Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
  • map() ->Creates a new array with the results of calling a provided function on every element in this array.
  • reduceRight() ->Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
  • reverse() ->Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first.
  • shift() ->Removes the first element from an array and returns that element.
  • sort() ->Sorts the elements of an array.
  • splice() ->Adds and/or removes elements from an array.
  • toString() ->Returns a string representing the array and its elements.
  • pop() ->Removes the last element from an array and returns that element.
  • push()->Adds one or more elements to the end of an array and returns the new length of the array.

Date Methods in JavaScript

  • getTime() ->Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC.
  • setTime() ->Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.
  • getTimezoneOffset() ->Returns the time-zone offset in minutes for the current locale.
  • getUTCDate() ->Returns the day (date) of the month in the specified date according to universal time.
  • setUTCDate() ->Sets the day of the month for a specified date according to universal time.
  • getUTCDay() ->Returns the day of the week in the specified date according to universal time.
  • getUTCFullYear() ->Returns the year in the specified date according to universal time.
  • getUTCHours() ->Returns the hours in the specified date according to universal time.
  • getUTCMilliseconds() ->Returns the milliseconds in the specified date according to universal time.
  • getUTCMinutes() ->Returns the minutes in the specified date according to universal time.
  • getUTCMonth() ->Returns the month in the specified date according to universal time.
  • getUTCSeconds() ->Returns the seconds in the specified date according to universal time.
  • getYear() ->Deprecated – Returns the year in the specified date according to local time. Use getFullYear instead.
  • setYear() ->Deprecated – Sets the year for a specified date according to local time. Use setFullYear instead.
  • setDate() ->Sets the day of the month for a specified date according to local time.
  • getDate() ->Returns the day of the month for the specified date according to local time.
  • setFullYear() ->Sets the full year for a specified date according to local time.
  • setHours() ->Sets the hours for a specified date according to local time.
  • setMilliseconds() ->Sets the milliseconds for a specified date according to local time.
  • setMinutes() ->Sets the minutes for a specified date according to local time.
  • getMonth() ->Returns the month in the specified date according to local time.
  • setMonth() ->Sets the month for a specified date according to local time.
  • getSeconds() ->Returns the seconds in the specified date according to local time.
  • setSeconds() ->Sets the seconds for a specified date according to local time.
  • setUTCFullYear() ->Sets the full year for a specified date according to universal time.
  • setUTCHours() ->Sets the hour for a specified date according to universal time.
  • setUTCMilliseconds() ->Sets the milliseconds for a specified date according to universal time.
  • setUTCMinutes() ->Sets the minutes for a specified date according to universal time.
  • setUTCMonth() ->Sets the month for a specified date according to universal time.
  • setUTCSeconds() ->Sets the seconds for a specified date according to universal time.
  • toDateString() ->Returns the “date” portion of the Date as a human-readable string.
  • toGMTString() ->Deprecated – Converts a date to a string, using the Internet GMT conventions. Use toUTCString instead.
  • toString() ->Returns a string representing the specified Date object.
  • toTimeString() ->Returns the “time” portion of the Date as a human-readable string.
  • valueOf() ->Returns the primitive value of a Date object.
  • Date() ->Returns today’s date and time
  • getDay() ->Returns the day of the week for the specified date according to local time.
  • getFullYear() ->Returns the year of the specified date according to local time.
  • toLocaleDateString() ->Returns the “date” portion of the Date as a string, using the current locale’s conventions.
  • toLocaleFormat() ->Converts a date to a string, using a format string.
  • toLocaleTimeString() ->Returns the “time” portion of the Date as a string, using the current locale’s conventions.
  • getHours() ->Returns the hour in the specified date according to local time.
  • getMilliseconds() ->Returns the milliseconds in the specified date according to local time.
  • getMinutes() ->Returns the minutes in the specified date according to local time.

Few important links for learning:-

  1. Want to know the difference between Function and Method in JavaScript? Just click here.
  2. Want to know what is function and how to use them in JavaScript? Just click here.
  3. Want to know what are variables and how to use them in JavaScript? Just click here.
  4. Let’s see an example for User form validation in JavaScript. click here.
  5. Let’s understand JavaScript. what and how? click here.
Tagged : / / / /

Methods in JavaScript

In JavaScript, however, a method is a function that belongs to an object. A JavaScript method is a property containing a function definition.

Few Important things of Methods:-

  • In JavaScript, however, a method is a function that belongs to an object.
  • JavaScript methods are the actions that can be performed on objects.
  • A JavaScript method is a property containing a function definition.
  • Accessing the object method is done with the following syntax: objectName.methodName()

Just similar to the functions in JavaScript methods are also classified in two categories:-

  1. Predefined
  2. User-defined

Predefined methods can be used directly by calling and giving parameter values (if required). while user-defined methods are first declared, defined, and then used in the program.

Deceleration and definitions of User-defined methods are done together we could understand better seeing the below code.
Syntax of Methods

object = {
    methodName: function() {
        // Content
    }
};

object.methodName()

How to access the Object Methods

we can access the object method with the following syntax stated below:-

objectName.methodName()

How to add the method to Object.

person.name = function () {
    return this.firstName + " " + this.lastName;
};

We could also directly use the built-in method.

var message = "Display message of your choice";
var x = message.toUpperCase();

The above method would just convert the text entered as a message to uppercase.

Few important links for learning:-

  1. Want to know the difference between Function and Method in JavaScript? Just click here.
  2. Want to know what is function and how to use them in JavaScript? Just click here.
  3. Want to know what are variables and how to use them in JavaScript? Just click here.
  4. Let’s see an example for User form validation in JavaScript. click here.
  5. Let’s understand JavaScript. what and how? click here.
Tagged : / / / / / /

Difference between Function and Method in JavaScript

So what’s the different between the two?

  • Methods have a “receiver” while functions do not.
  • Functions and methods are the same in JavaScript, but a method is a function, which is a property of an object.
  • Syntax for calling/ definition/declaration of functions and methods are different.
  • A function can be called directly by its name but methods are called by its object name and its method name using dot notation or square bracket notation.
  • Function passes the data and methods operates the data passed in the class.
  • A function lives on its own but method is a function associated with an object property.
  • Data passed to a function is explicit but method implicitly passes the object on which it was called.

Lets see detailed difference between them:-

A function in JavaScript is similar to a procedure —>a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output

Few Important things of functions:-

  • The function is executed when something calls/invokes it.
  • The name may contain letters, digits, dollar signs, underscore.
  • Parameters are listed inside round parenthesis after the name of the function.
  • Arguments are values a function receives when it is invoked.
  • When the control reaches the return statement, js will stop executing and the value is returned to the caller.

There are three steps of Functions as well as Methods to use in the program.

  1. Declaration
  2. Definition.
  3. Call

In JavaScript function declaration and definition are mostly done together.

A JavaScript method is a property of an object that contains a function definition. Methods are functions stored as object properties.

Few Important things of Methods:-

  • In JavaScript, however, a method is a function that belongs to an object.
  • JavaScript methods are the actions that can be performed on objects.
  • A JavaScript method is a property containing a function definition.
  • Accessing the object method is done with the following syntax: objectName.methodName()

Syntax of Function

var func = function(a, b) {
    var sum = a + b;
    return sum;
}
  
console.log(sum(1, 2));

Syntax of Methods

object = {
    methodName: function() {
        // Content
    }
};

object.methodName()

Few important links for learning:-

  1. Let’s see an example for User form validation in JavaScript. click here.
  2. Let’s understand JavaScript. what and how? click here.
  3. Want to know what is function and how to use them in JavaScript? Just click here.
  4. Want to know what are variables and how to use them in JavaScript? Just click here.

Tagged : / / / /

Predefined Functions in JavaScript

Want to know what is function and how to use them in JavaScript? Just click here.

Every computer programming language has functions. Some functions are defined by the programmers while the code is being written while some functions are predefined when the language was built.

As every functions have three parts

  1. Function Declaration
  2. Function Definition.
  3. Function Call

In predefined functions, the first two points are already done inside the library which we include as a header file at the beginning of the program. we just have to call the function.

Few most common predefined functions that we use are:-

Functions to display something in JavaScript:-

alert(message– It displays an alert box with a message specified in it.

confirm(message) – It will display the message with two buttons. “OK” and “Cancel”.

prompt(message) – Displays a box with the message passed. There the user can enter text in the prompt field, and choose OK or Cancel. If the user chooses OK, the string value entered in the field is returned and If the user chooses Cancel, a NULL value is returned.

Functions for conversion in JavaScript:-

parseFloat() – It returns floating-point numbers the same way as the parseInt function does, but looks for floating-point qualified strings and returns their value as afloat.

parseInt()– It converts a string to an integer returning the first integer encountered which is contained in the string. If no integer values are found such as in the string “written text”, then a value of 0 is returned.

Functions for comparison in JavaScript:-

eval()– Converts a string to integer or float value.

isNaN(value) – If the value passed is not a number, the boolean value of true is returned, if it is a number, it returns false.

escape(string) – It passes the string to be encoded and returns the encoded string. Encodes a string from ASCII into an ISO Latin-1 (ISO 8859-1) character set for HTML processing.

unescape() – Converts an ISO8859-1 character set to ASCII.

isFinite() – function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.

Functions for decoding and encoding in JavaScript:-

decodeURI() function decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine. decodeURIComponent()

decodeURIComponent() method decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent() or by a similar routine. encodeURI

encodeURI() encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two “surrogate” characters). encodeURIComponent()

encodeURIComponent() encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two “surrogate” characters).

There are more predefined functions but these were the important ones which are often used.

Few important links for learning:-

  1. Let’s see an example for User form validation in JavaScript. click here.
  2. Let’s understand javascript. what and how? click here.
  3. Want to know what is function and how to use them in JavaScript? Just click here.
  4. Want to know what are variables and how to use them in JavaScript? Just click here.
Tagged : / / / /

A must things to do when we import new databases in any Laravel project.

Whenever we import the database we need to install the passport as it is not able to access the previous client secret. We need to change the new client secret after it is installed in the projects to all the locations required.

php artisan passport:install

For generating key we use the following command

php artisan key:generate

Then we need to run few commands for convenience so that we don’t get errors.

php artisan c:cache
php artisan r:cache
php artisan r:clear
php artisan config:clear
php artisan view:clear

If the error shows as Replicating claims as headers are deprecated and will remove from v4.0. Please manually set the header if you need it replicated. then run the following command

composer require lcobucci/jwt=3.3.3

We can also check for updating composer and for this we use command

php artisan composer:update

to link the storage we need to run following command

php artisan storage:link

We can also do for our convenience migrating the database, for this we use command

php artisan migrate 

For refreshing the migration table

php artisan migrate:refresh

Tagged : / / /

Function in JavaScript

What is a Function in JavaScript

A JavaScript function is a block of code designed to perform a particular task. In simple terms, Functions are used to make work easy, reduce the effort of coding multiple lines for the same task which is needed to repeat multiple times.

There are three parts of the Function.

  1. The keyword function with the function name.
  2. Function parameter (if it is parameterized).
  3. Function body (Contains the instructions part).
  4. Return statement.

There are three steps of Function to use in the program.

  1. Function Declaration
  2. Function Definition.
  3. Function Call

In JavaScript function declaration and definition are done together.

The syntax for function Declaration & Definition.

  1. We need to declare the function name starting with the keyword function.
  2. After that, we need to open and close the parenthesis (to pass the parameter/s).
  3. Then we need to open the brackets (to write the function body).
  4. In the last line, we need to put the return statement.
  5. Now we need to close the brackets.

An example of function definition and declaration is shown below:-

function toCelsius(fahrenheit) {
  return (5/9) * (fahrenheit-32);
} 

Different ways for function Call

There are four ways we can call the function in JavaScript.

  1. As a function (we can use the log function)
function sayHello() {
      console.log('hello');
    }

2. As a method (we can use function name followed by . then the method name )

document.getElementById("demo").inner HTML = "Hello! I called myself"; 
or
function_name.object_name();
or with call method
function_name.object_name.call();
and many more.

3. As a constructor (In sayHello function, we grab the value in the text box and create a new instance of the Greeter object by calling new Greeter().)

function Greeter(name) {
      console.info('begin constructor');
      console.log(this);
      console.log(arguments);
      this.name = name;
      console.info('end constructor')
    }
    function sayHello() {
      var name = document.getElementById('name').value;
      var grtr = new Greeter(name);
      console.log('hello ' + grtr.name);
    }

4. via call() and apply()

Few codes for function in JavaScript:-

We could also use Functions as Variable Values

function toCelsius(fahrenheit) {
  return (5/9) * (fahrenheit-32);
}

Instead of using a variable to store the return value of a function:

var x = toCelsius(77);
var text = "The temperature is " + x + " Celsius";

We can use the function directly, as a variable value

var text = "The temperature is " + toCelsius(77) + " Celsius";

For understanding a brief description of JAVASCRIPT click here

For understanding ariables in JavaScript (var/let/const) click here

For understanding, registration-form-validation-using-javascript click here

Tagged : / / /