Skip to main content

Posts

(Laragon) Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)

 Go to laragon folder open bin then php then php-7.2.19-win32-VC15-x64 and open php.ini file. and after opening php.ini file search memory_limit and you will probably get memory_limit=512M and you have to change the memory_limit from 512 to -1.  In this link  https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors it is mentioned that: Use - 1 for unlimited or define an explicit value like 2G Now, restart laragon and in the terminal you can install your desired composer package example:  composer require tymon/jwt-auth Thanks

npm run watch error in laravel 8

 When you try scaffolding or for any js compiling reason you would have tried npm install and npm run watch at any point of time in laravel. well, now i have seen that i am getting error while trying npm run watch to compile the mix file.  solution to that is simply run :  npm run development -- --watch It will do the same as npm run watch. it will compile all the asset files as before.

How to show the remaining days in php

{{  \Carbon\ Carbon :: parse ( $salesmantarget -> month_year )-> format ( 'F j, Y' )  }}              <?php                  $OldDate  =  strtotime ( $salesmantarget -> month_year );                $NewDate  =  date ( 'M j, Y' ,  $OldDate );                $diff  =  date_diff ( date_create ( date ( "M j, Y" )), date_create ( $NewDate ));                               if ( $diff -> format ( "%R%a days" ) >  0 )           ...

Current Server Discovery and Monitoring Engine is Deprecated

When building connection using mongoose you might get an error saying Current server discovery and monitoring engine is deprecated.  Error:  current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. So, basically two of the options need to be passed to the mongoose.connect method.  so these are:{ useNewUrlParser: true} and {useUnifiedTopology: true} See the example below: mongoose . connect ( "mongodb://localhost:27017/fruitsDB" , {    useNewUrlParser :   true ,    useUnifiedTopology :   true , }); Here, fruitsDB is the database name. Now, if you run your file say for example app.js, you will not that error again.

MongoDB Setup Guide for Beginner

Why MongoDB? Answer:  MongoDB stores data in flexible , JSON-like documents. Think like this is json database. What makes everything easy with json database is maping of the object. when you store anything in tables,rows and columns, accessing the data can be little bit challenging, and can be costly process  for your processor. But on the other hand, in the NoSql since everything is stored in mapping of key value pair, it is easier+faster and everything becomes easy  and simple with that. Scalability is challenging in mysql database.  This kind of scaling is super easy  in mongoDB . So it's getting high in demand on scalability. changing schema is so much easy. Drawbacks with mysql and other relational database is:  1) Hard to understand 2) Adding features harder 3) Inefficiant MongoDB solved this problems. who is using mongoDB? Amazon web services, Microsoft Azure, Google Cloud Platform a...

laravel snappy pdf

Install this: https://wkhtmltopdf.org/downloads.html then install this two, $ composer require h4cc/wkhtmltopdf-i386 0.12.x $ composer require h4cc/wkhtmltoimage-i386 0.12.x Then, composer require barryvdh/laravel-snappy Then, php artisan vendor:publish --provider= " Barryvdh\Snappy\ServiceProvider " And Now, copy the wkhtmltopdf.exe and wkhtmltoimage.exe files to the above h4cc folder which is present inside vendor folder of laravel. and set the path to snappy.php file-> see the snappy.php file which is given below: [NOTE: see the code which i've commented out. You can run & check every line of code] Route :: get ( '/' ,  function  () {      $data  = [         [              'name' => 'Audi' ,              'logo' => 'audi.jpg' ...

Eloquent Relationship Explained (MANY TO MANY) with attach,detach,sync

When you create a brand new project you have users table and User model already by default. So, now create another table with model: php artisan make:model Role -m This will create Role model as well as roles table. Now as it is many to many relation. So we need a pivot table. Pivot table naming convention: role_user Here role is written first as because alphabetically r comes before u. and laravel eloquent relationship takes in this way. So, you should remember this always. and use _ in between role and user. like: role_user So, let's create role_user table. php artisan make:migration create_role_user_table --create=role_user naming covention of pivot says that role_user table is singular. users table includes: id name, email pivot table role_user includes: user_id role_id roles table includes: id name migrate it all. Many to Many Relation: Go to User model and write: public function roles(){  r...