Skip to main content

Posts

Unsubscribing an observer while running create, update or delete operations on modal in Laravel

Today I was trying to copy some data from one application to another application. The Data has some nested relationships so I created a custom feature to fetch the data using Apis and insert them one by one into my destination application. My problem while inserting the data was, there was an observer is set to File.php (for example) model that was running run logic to upload the incoming file to AWS s3 Cloude storage. But I am not really uploading anything while inserting the data. So, I want to stop the Observer from running the functionality while I was running my custom feature. While looking for some solution to my problem I came to a solution that I would like to share with you. File::unsetEventDispatcher(); I used this function call before running the logic only once and my observer stopped executing the code on Create and Update model event. You can also use the same code to stop the other event from executing while running some logic. You can get all the event displachers and
Recent posts

You are running 'create-react-app' 4.0.3 which is behind the latest release (5.0.1).

I was trying to create a new React app with the following command. > npx create-react-app react-app Then I get the following error: You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.1). We no longer support global installation of Create React App. I also get some help instructions as well as: Please remove any global installs with one of the following commands: - npm uninstall -g create-react-app - yarn global remove create-react-app I tried to run the floowing command multiple times as suggested: > npm uninstall -g create-react-app Which ran fine with no error that means my create-react-app glabal installation uninstalled successfully. Then I again tried the same command to install the React app: > npx create-react-app react-app But I again get the same errors and suggestions. I repeated the same procedure multiple times but it did not work. Then I decided to look for the solution over a search engine. By no much time, I got some useful help th

Call async function in loop for array and update the exiting array Javascript and Node Js

Here is a good example of the code to call async function in loop for element of an array and update the exiting array. In this example I have used the Array.prototype.entries() function to get the index and value of each array item of a simple array. Array.prototype.entries() method helps to iterate an array with index and element. function timeout(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function resolveAfter2Seconds(num) { await timeout(2000); return num; } async function main() { let arr = ["Saab", "Volvo", "BMW"]; for (let [index, val] of arr.entries()) { console.log(index, val); console.log(await resolveAfter2Seconds(val)); } } main();

Scanning QR code without installing App on Android Mobiles

     Hello friends, QR code is a machine readable bar code that contains information about the items like mobile number, web page URL, Wi Fi settings, mobile app installation URL etc. We see QR code have a lot of times every day on many places. QC code save out time and efforts to manually type such information in our devices.      The problem is that  not all devices have built in camera support to scan the QR code so we need to install new application from play store to be able to read the QR code but I figure out a very nice way to scan a QR code without any additional support.      An android deice have google search app installed by default and google photo search comes with the QR code reading capability by default and its going to be very handy to use this feature as the google search provides a search widget at Home screen of the android mobile or tablet. How to scan QR code with google photo search: 1. Open your mobile and search for this google search widget on your home scre

Windows Updates And Cool New Features

Hi Friends, Yesterday I got heavy Window 10 updates and after these updates got installed into system the system looks somewhat different. The very first change that I notice was a new Icon on my task-bar. An icon of Mail application. When I click on this icon then I come to know this very good application and I personally looking for such kind of solution for my Gmail account. This app helps me to set up my Gmail account with ease. The mail app also has a calendar app associated with it that helps me to get all google calendar events on my system that will work for when I will be offline. The other great feature and what I think awesome new feature  Paint  3D . Yes, you read it right paint 3d. Using this new application anyone can create 3D models and edit them from all angles. I think young boys are going to be mad with this creative application. I am continuing to explore the new updates and try to update here as well.

Get Google Calender's Event Notifications Or Reminder Notifications On Windows

Hi Friends, I was struggling for some days to get better notifications for google calender's events or reminders that I have set for myself but I was able to only get the browser notifications that was not quite working for me. I am not satisfied the way those browser notifications work for any calendar event or alert. The cons of browser notifications are: 1. They can't be snooze 2. They didn't sustain for long time, they just appears for 1 or 2 min maximum. 3. They are not very attractive. They can be missed easily. For these reasons the browser notifications are not a good solutions for Calendar notifications. So I searched on internet for any solutions that can provide me to get better notification for my google calendar events. By change today I get a window update today and I come to know about the Mail  app on  Window 10. This simple mail client app asked me to set up account with Google account and then it synced all my mails and calendars from my google a

Beginning with PHP development with your first php code.

PHP is a server scripting language that is mainly suitable for web page or web application development. PHP pages can also have HTML, CSS and Javascript  in it. By default PHP can be write in a file with .php extension like 'filename.php'. System Requirements  for PHP Development: (On Window OS) The all in one solution for PHP development on window machine are : WAMP and XAMPP server stack that have web server (Apache) , PHP and database server (Mysql) in it. You can download WAMP server from here or the XAMPP server from here. One of the best thing with these server is that they are open source and free to use. Tools you can use: Notepad++ : This is a text editor that can be used to write your PHP code. Download the Notepad++ from here . Step to write you first PHP code: Install the WAMP/XAMPP server. Create a new file in Notepad++ (Or any text editor you have) Write the below code in the file. Code of index.php file Save the file as "inde