InfyOm Blog

latest-post

In this article, I show you an easy way to set up browser push notifications. fist of all, you have a question what is push notification? let me explain a bit more. Push notification is the fastest way to get up and running with Javascript desktop notifications. Push notifications are messages that can be sent directly to a user's Desktop via browser.

You can watch the following tutorial and you can continue reading this article.

Follow the Steps given here for setup push notification.

Step 1: You can quickly install Push via npm

npm install push.js --save

Step 2: Update webpack.mix.js

Add following code into webpack.mix.js for copy and publish assets like js in the public directory. you can see the example here

mix.copy('node_modules/push.js/bin/push.min.js',
    'public/assets/js/push.min.js');

I hope you know how to use laravel mix. you can watch this video tutorial if you want to know more about the laravel mix.

fire, npm run dev command and publish js.

Step 3: Add assets in blade file

Add script before closing body tag.

Step 4: Add this code where you want to show a push

// add logo in public dir and use it here
const iconPath = '{{ asset('logo.PNG') }}
 Push.create("Hello Shailesh!",{
       body: "Welcome to the Dashboard.",
       timeout: 5000,
       icon: iconPath
});
December 03, 20213 MinutesuserShailesh Ladumor

Posts

post

Most of the developers are facing a select2 style removing issue when livewire renders the component.

We can resolve this issue by using a livewire javascript hook.

Here is my screen with select2 before livewire component rendering.

2020-12-10_5fd2207b2f583

And when the livewire component is refreshed means re-render the select2 style is gone ☹️

2020-12-10_5fd221ec084b8

How to Fix it ?? 🤔

Well, you just need to add some JQuery code to your livewire component. Here we are going to use afterDomUpdate webhook of livewire. add the following code to your livewire component :

document.addEventListener('livewire:load', function (event) {
   window.livewire.hook('afterDomUpdate', () => {         
   $('#select2ID').select2();     
   }); 
});

livewire:load is listening events when the livewire component is loaded and we can add our code within it.

And now when your livewire component is refreshed your select2 style will be still there as we are again applying it.

Other Livewire Posts:

Stay tuned to us for more interesting stuff about livewire.

September 03, 20201 minuteauthorVishal Ribdiya
post

Software Testing Life Cycle (STLC) identifies the test activities to perform and when to perform those test activities. While testing differs between organizations, there is a test lifecycle.

There are mainly eight phases of STLC

  1. Requirement Analysis
  2. Test Planning And Control
  3. Test Analysis
  4. Test Case Development
  5. Test Environment Setup
  6. Test Execution
  7. Exit Criteria Evaluation And Reporting
  8. Test Closure

2020-12-10_5fd21d73795c8

Requirement Analysis:-

The entry criteria for this phase is the BRS document (Business Requirements Specification). During this phase, the test team studies and analyzes the requirements from a test perspective.

This phase helps to identify whether the requirements are likely or not. If any requirement is not verifiable, the test team can communicate with various stakeholders (customer, business analyst, technical leaders, system architects, etc.) during this phase so that the mitigation strategy can be planned.

Entry criteria: BRS (Business Requirement Specification) Results

Deliverables: list of all verifiable requirements, automation feasibility report (if applicable)

Test Planning And Control:-

Test planning is the first step in the testing process. At this stage typically Test Manager Test Lead involves determining the effort and cost estimates for the entire project. The preparation of the Test Plan will be made on the basis of the requirements analysis. Activities such as resource planning, determination of roles and responsibilities, selection of tools (if automation), training requirements, etc., are carried out at this stage.

The deliverables of this phase are Test Plan & Effort estimation documents.

Entry Criteria: Requirements Documents

Deliverables: Test Strategy, Test Plan, and Test Effort estimation document.

Test Analysis:-

Test Analysis Is the process of analyzing the test basis (all documents from which the requirements of a component or system can be inferred) and defining test objectives. It covers WHAT is to be tested in the form of test conditions and can start as soon as the basis for testing is established for each test level.

Following Is The Document Which Is Use In Test Analysis:-

  • CRS (Customer Requirement Specification)
  • SRS (Software Requirement Specification)
  • BRS (Business Requirement Specification)
  • Functional Design Documents

Test Case Development:-

This phase begins after the test planning and analysis phase is completed. From test analysis, we can understand how to test and what the test condition is. So easily understand and develop the test case. In This phase, the evaluator creates the manual / automation test scripts. The test data is prepared in this phase and the data is used to find the defect. The Requirement Traceability Matrix (RTM) is also ready Because the evaluator understands tracking the test case for the particular requirement.

2020-12-10_5fd21d8345df1

Activities in the Test Case Development Phase

Following are the three activities that are carried out in the Test Case Development phase

Test Scenarios Identification

  1. Scenarios ease the testing and evaluation of a complex system. The following strategies help in creating good scenarios −
  2. Enumerate potential users, their actions, and their goals.
  3. Evaluate Users who have a hacker mindset and listed possible scenarios for abuse of the system.
  4. List System events and how the system handles these requests.
  5. List Benefits and create comprehensive tasks to verify.
  6. Read about similar systems and their behavior.
  7. Studying Complaints about competitors' products and their predecessors.

Test Cases Writing

A test case is a document, which includes test data, preconditions, expected results, and postconditions, developed for a particular test case in order to verify compliance with a specific requirement.

Test Case serves as a starting point for running the test. After a set of input, values ​​are applied; the application is final and leaves the system at an endpoint also known as a post-execution condition.

Test Data Preparation

Test Data is used to run the tests for test ware. Test Data must be precise and complete in order to detect the shortcomings. To achieve these three goals, follow a step-by-step approach as given below -

  1. Identify resources or test requirements
  2. Identify conditions/functionality to be tested
  3. Set priority test conditions
  4. Select conditions to test
  5. Determine the expected result of test case processing
  6. Create Test cases
  7. Document test
  8. conditions Conduct test
  9. Verify and correct test cases based on modifications

Activity Block Diagram

The following diagram shows the different activities that form part of Test Case Development.

2020-12-10_5fd21d921ebbe

Test Environment Setup:-

A test environment is a software and hardware configuration that allows test teams to run test cases. In other words, it supports running tests with configured hardware, software, and network. The testbed or environment is configured as needed Application Under Test. On some occasions, the test may be the combination of the test environment and the test data that it operates. Setting a good test environment guarantees successful software testing. Any Loopholes in this process can result in additional costs and time for the customer.

Process of Software Test environment setup

Tests are limited to what can be tested and what not should be tested.

Following people are involved in test environment setup

  • System Admins,
  • Developers
  • Testers
  • Sometimes users or techies with an affinity for testing.

The test environment requires setting up of a various number of distinct areas like,

Setup of Test Server

Test Every may not be performed on a local machine. It may need to create a test server that can support applications.

For example, Fedora configuration for PHP, Java-based applications with or without mail server, cron configuration, Java-based applications, and so on.

Network

Network set up as per the test requirement. It includes,

  • Internet setup
  • LAN Wi-Fi setup
  • Private network setup

It ensures that the congestion that occurs during testing doesn't affect other members. (Developers, designers, content writers, etc.)

Test PC setup

For web testing, you may need to set up different browsers for different testers. For desktop applications, you need various types of OS for different testers' PCs.

For example, Windows phone app testing may require.

  • Visual Studio installation
  • Windows phone emulator
  • Alternatively, assigning a Windows phone to the tester.

Bug Reporting

Bug reporting tools should be provided to testers.

Creating Test Data for the Test Environment

Many companies use a separate test environment to test the software product. The common approach used is to copy production data to test. This helps the tester to detect the same issues as a live production server, without corrupting the production data.

The approach for copying production data to test data includes,

  • Set up production jobs to copy the data to a common test environment
  • All PII (Personally Identifiable Information) is modified along with other sensitive data. The PII is replaced with logically correct, but non-personal data.
  • Remove data that is irrelevant to your test.

Testers or developers can copy this to their individual test environments. They can modify it as per their requirement.

Privacy is the main issue in copy production data. To overcome privacy issues you should look into obfuscated and anonymized test data.

For Anonymization of data two approaches can be used,

  • Blacklist: In this approach, all the data fields are left unchanged. Except those fields specified by the users.
  • Whitelist: By default, this approach, anonymizes all data fields. Except for a list of fields that are allowed to be copied. A whitelisted field implies that it is okay to copy the data as it is and anonymization is not required.

Also, if you are using production data, you need to be smart about how to source data. Querying the database using SQL script is an effective approach.

Every test may not be executed on a local machine. It may need establishing a test server, which can support applications.

For example, Fedora set up for PHP, Java-based applications with or without mail servers, cron set up, Java-based applications, etc.

Network

Network set up as per the test requirement. It includes,

  • Internet setup
  • LAN Wi-Fi setup
  • Private network setup

It ensures that the congestion that occurs during testing doesn't affect other members. (Developers, designers, content writers, etc.)

Test Execution:-

After The test plan, the development of the test case, and the configuration of the test environment are complete, and then the execution phase of the test is executed.

This manual test/automation script phase is executed. If any defect is detected during the execution of the test case, it will be reported to the developer through the bug tracking system.

If any test case result is a failure then this particular test case is marked as a failure.

If any test case result is matched to the expected result then a particular test case is marked as Pass.

If all module dependencies are tested and any fault is detected, the particular module test case is marked as blocked, first corrects the main module fault, and then runs the associated module test case. For example, B depends on module A.

If any fault is found in module A, the test case of module B is not executed. First correct the fault of module A then rerun the module A test case, If module A the result of the test case is Pass then run the module B execution of the test case.

Blocked Test noticed cases are executed after the fault is corrected by the developer.

2020-12-10_5fd21da3e8622

Exit Criteria Evaluation And Reporting:-

In this phase, if the exit criteria match the test result. In Termination Criteria, There is one condition that is predefined. At this stage, The test summary report is generated. A Document containing a summary of testing activities and final test results is called Test Summary Report.

Test Closure:-

In the final stage where we prepare the Test Closure Report, Test Metrics.

The testing team will be called out for a meeting to evaluate cycle completion criteria based on Test coverage, Quality, Time, Cost, Software, Business objectives.

The test team analyses the test artifacts (such as Test cases, defect reports, etc.,) to identify strategies that have to be implemented in the future, which will help to remove process bottlenecks in the upcoming projects.

Test metrics and Test closure reports will be prepared based on the above criteria.

Entry Criteria: Test Case Execution report (make sure there are no high severity defects opened), Defect report

Deliverables: Test Closure report, Test metrics

August 31, 20208 minutesauthorBhumi Khimani
post

After doing all the right things to boost productivity and still employees' productivity plunging or not increasing, we need to look at the Employee Morale. Employee Morale is a decisive factor in an Organisation whether it is the Service sector or Manufacturing unit. It is one of the cornerstones of the business, only a few organizations pay attention to morale among employees in their organization and this is the major mistake from their side as it affects productivity which ultimately reflects in Organizational Growth & Productivity.

Let’s Discuss:

  • What’s Employee Morale?
  • Characteristics of Employee Morale.
  • Relation between Morale & Productivity.

What is Employee Morale?

In simple terms employee morale is the standard of behavior of an employee which directly affects the productivity of the organization but it is a complex concept as there are ample factors that affect employee morale.

Definition:

Edwin Flippo: “ Morale is a mental condition or attitude of individual and groups which determines their willingness to cooperate”

Characteristics:

  • Psychological concept
  • Dynamic Nature
  • Group phenomenon
  • Reflect others

Psychological Concept:

Morale is a psychological phenomenon, it is the internal feeling of confidence, attitude, Zest, enthusiasm, satisfaction, etc. Moreover, it is the state of mind and emotions affecting the attitude and willingness to work that affect individual and organizational objectives.

Dynamic Nature:

Morale is Dynamic in nature; we cannot develop it overnight. Management has to make continuous efforts to build and maintain high morale among employees in the organization. It is a long-term concept.

Group Phenomenon:

Morale is not an individual phenomenon but it's the sum of the total employee’s attitude, feelings, and sentiments.

Reflect others:

We cannot measure morale directly but it is reflected in productivity, discipline, turnover, etc. To measure morale we need to look at other factors.

Relations between Morale and Productivity:

Davis Designed that there is not always a positive link between Productivity and Employee morale. There can be four combinations of Morale and Productivity

employee-morale-play-significant-role-in-business-development/1

1. High morale-High productivity

This situation is likely to occur when the employees are fully motivated to achieve high performance not only this but satisfied with all financial & nonfinancial rewards & highly satisfied with their job role. Feeling proud to be part of the organization/team.

2. High morale-low productivity

This situation occurs when the employees waste their time in the workplace or use the time to satisfy their personal goals. They don't care about organizational goals. There are many factors responsible for this kind of Employee Attitude in the workplace such as

  1. Lack of proper training,
  2. Lack of support by co-workers or leaders,
  3. Leaders/Superior behavior with him,
  4. Irresponsible Management (If we talk about It or another small service sector Irresponsible HR )
  5. Ineffective Supervision
  6. Restrictive norms of the informal group
  7. Outdated Technology & Methods

3.Low morale-High productivity

In a short period, it may be possible that with low morale Employee's productivity seems high but it is for a temporary or short span of time. Low Morale can not result in high productivity for a long time. this situation occurs when

  1. Fear of losing a job,
  2. Less availability of alternatives
  3. Strict Supervision, Rules & Regulations
  4. Punishment
  5. Policies and strategies focus on high productivity only.

4. Low morale-Low productivity

This situation occurs when the organizational & individual goals are not satisfied & other factors like

  1. Lack of motivation
  2. Unclear Job role
  3. Lack of harmonious Superior-Subordinate relationship

These all factors result in frustration, tension and grievances develop against managers which reflect low productivity. To pen down, morale is the paramount factor that gives a direct impact on productivity, Productivity impact on profitability, profitability impact on organizational growth. If the Morale is high then it will be possible to gain more fruits in the future but if it's low then it's Red Signal for any organization even the productivity is high but it will be for a short period of time only

I am not going to end the topic of Morale but will continue in the next blog with

  1. Factor determining morale
  2. Significance of high morale
  3. Impact of low morale
  4. Measurement of morale

To know about these please read my upcoming blogs of Human Resource…..

August 25, 20203 minutesauthorMariyam Bemat
post

Software testing is a process of checking and validating the functionality of an application to determine if it meets specified requirements. It is about finding application faults and verifying where the application is operating according to the end-user needs.

Important Software Testing Techniques:-

  • Boundary Value Analysis (BVA)
  • Equivalence Class Partitioning
  • Decision Table based testing.
  • State Transition
  • Error Guessing
  • Boundary Value Analysis (BVA)
  1. The marginal cost assessment is based entirely on trying the boundaries between partitions. It includes maximum, minimum, internal, or external barriers, typical values, and error values. It is generally seen that numerous errors occur at the obstacles of the defined input values as opposed to the center.

  2. It is also known as BVA and offers a selection of test entities that train limit values. This black container test method improves equivalence partitioning. This software program trying one approach is based on the principle that if a machine works well for these exact values, it will paint error-free for all values that are between the two limits.

Let's see one example:

Input condition is valid between 1 and 10 Boundary values 0,1,2 and 9,10,11

Equivalence Class Partitioning

The equal class phase lets you divide a hard and fast check state into separate sections which are taken into consideration identical. The equal class division software program test technique breaks the input area of a program into a class of information, so a test case has to be designed.

Let’s see one example:

Input conditions are valid between

1 to 10 and 20 to 30

Hence, there are five equivalence classes

--- to 0 (invalid)

1 to 10 (valid)

11 to 19 (invalid)

20 to 30 (valid)

31 to --- (invalid)

You select values from each class, i.e.,

-2, 3, 15, 25, 45

Decision Table Based Testing

The decision table is known as the cause and effect table. This testing technique is suitable for input features that have a logical relationship between inputs. In this technique, combinations of inputs are processed. In order to identify the test case with the decision table, it is necessary to consider the terms, actions, and procedures. Conditions are taken as input and actions as output.

Testing Using The Decision Table In The Login Form

software-testing-technology/1

CONDITIONS - CASE 1, CASE 2, CASE 3, CASE 4

| EMAIL | F | T | F | T | PASSWORD | F | F | T | T | OUTPUT | ERROR | ERROR | ERROR | HOME SCREEN

CASE 1: Email And Password Wrong: Error Message Displayed.

CASE 2: Email True And Password Wrong, Error Message Displayed.

CASE 3: Email Wrong And Password True, Error Message Displayed.

CASE 4: Email And Password True, Redirect to Home screen

State Transition Testing Technique

In-State Transition technique changes in input conditions change the state of the Application Under Test (AUT). This testing technique allows the tester to test the behavior of an AUT. The tester can perform this action by entering various input conditions in a sequence. In-State transition technique, the testing team provides positive as well as negative input test values for evaluating the system behavior.

Presently We Make A Diagram For Forgot Password/OTP Proces

software-testing-technology/2

software-testing-technology/3

  1. First Enter the Right Number In This Text Box and Click RESET PASSWORD Button. One OTP Comes On Mobile Number.
  2. To reset the secret word you should experience the "OTP'' framework. The first run-through the client enters is "OTP '', they will be permitted to go to the secret phrase change page.
  3. In the event that the client enters mistaken "OTP '' unexpectedly and second, the framework will request the third time "OTP'' is entered.
  4. In the event that "OTP'' is valid, it will be permitted to go to the secret phrase change page, in any case, if the OTP is off base the third time, an Error Message Displayed Like "Your OTP has expired!!".

State Transition Table

ATTEMPT CORRECT PIN INCORRECT PIN

| [B1] Start | B5 | B2

| [B2] First attempt | B5 | B3

| [B3] Second attempt | B5 | B4

| [B4] third attempt | B5 | B4

| [B5] Access granted | - | -

| [B6] Account blocked | - | -

Error Guessing Technique

Error guessing is a software testing technique based on guessing the error that can appear in the code. The technique relies heavily on experience, with the test analysts using their experience to guess the problematic part of the test application. Therefore, test analysts need to be competent and experienced in order to better guess errors. The technique counts a list of possible errors or error-prone situations. Then the tester writes a test case to uncover these errors. To design test cases based on this software testing technique, the analyst can use the experience to identify the conditions.

This technique can be used at any level of testing and for testing the common mistakes like:

  • Divide by zero
  • Inserting blanks in text fields
  • Pressing the enter button without entering values
  • Uploading files that exceed the maximum limits
  • Exception null pointer.
  • Invalid parameters

Let’s see one example:

Suppose there is a requirement that the phone number be numeric and not less than 10 characters. And the software application has a phone number.

The following are the error estimation techniques:

  1. What will be the result if the cellphone number is left blank?
  2. What is the result if a character other than a digit is entered?
  3. What is the result if fewer than 10 digits are entered?
August 22, 20204 minutesauthorBhumi Khimani
post

We work on projects with the admin panel every day. In which we mostly use data tables and we need to delete the record from the data table without page refresh.

So, today I will show you how to extract a record using Ajax. It's very easy to integrate.

Let's take one example. I have a Category data table and I want to delete one category from the table without refreshing the page. Now, what am I doing for that? First of all, I add a class for the listen to a click event into the delete button and it says delete-btn.

See the following image for where I added a class.

delete-record-using-ajax-in-laravel/1

I used SweetAlert for the confirmation popup. let add sweet alert's CSN into the index.blade.php.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css"> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>

Let's declare routes of the delete record.

<script>let categoryUrl = '{{route('categories.index')}}'; </script>

Next steps, I'm going to listen to the click event of the delete button. one more thing does not forget to add the record id into the data attribute to the delete button. see the above image for it. I highlighted it with a yellow line.

So the general practices we use in Laravel is to write the following code to listen to a click event and delete a record,

$(document).on('click', '.delete-btn', function (event) {             
           const id = $(event.currentTarget).data('id');

  swal({ 
      title: 'Delete !',                     
      text: 'Are you sure you want to delete this Category" ?',                     
      type: 'warning',                    
      showCancelButton: true,                     
      closeOnConfirm: false,                     
      showLoaderOnConfirm: true,                     
      confirmButtonColor: '#5cb85c',                     
      cancelButtonColor: '#d33',                     
      cancelButtonText: 'No',                     
      confirmButtonText: 'Yes',                 },                 
          function () {                    
                   $.ajax({                 
                       url: categoryUrl + '/' + id,                 
                       type: 'DELETE',                 
                       DataType: 'json',                 
                       data:{"_token": "{{ csrf_token() }}"},                 
                       success: function(response){                     

                              swal({                                 
                                  title: 'Deleted!',                                 
                                  text: 'Category has been deleted.',                                 
                                  type: 'success',                                 
                                  timer: 2000,                             
                              });                     
  $('#categoryTbl').DataTable().ajax.reload(null, false);                 
              },                 
               error: function(error){                     
               swal({                                 
                   title: 'Error!',                                 
                   text: error.responseJSON.message,                                 
                   type: 'error',                                 
                   timer: 5000,                             
              })                     
            }             
        });                 
    });         
});

Now we are done with the front-end side and need to look into it backend side.

Let's declare the destroy method into the category Controller. I hope are you generating crud with InfyOm Laravel Generator. so, the Destroy method and routes are there. If not please create a route. if the destroy method is there then need to change the response of that method.

The destroy method code looks like,

 public function destroy($id)     { 
        $category = $this->categoryRepository->find($id);
        if (empty($category)) {
            Flash::error('Category not found');

            return $this->sendError('Category not found.');
        }

        $this->categoryRepository->delete($id);

        return $this->sendSuccess('Category deleted successfully.');
    }
August 19, 2020authorShailesh Ladumor
post
  • Developer use API calling retrofit, volley JSON or other tools but API response check-in postman time confusion how to creating this response model class
  • So a friend in this topic I will try your confusion remove flow below all steps and 5 min inner creating a wonderful model class

Step: 1 Android studio in install "RoboPOJOGenerator"

  • Location in the android studio:
  1. Open android studio
  2. Go to File
  3. Go to Setting
  4. Click plugin
  • check the below image && click and install RoboPOJOGenerator then your android studio restart

Step: 2 How to open RoboPOJOGenerator

  1. Open android studio
  2. Go to File
  3. Select directory below the image in showing related select any one directory
  4. Right-click - select New - then below showing "RoboPOJOGenerator"

Step: 3 How to add postman response

  1. Postman response copy
  2. Paste this response in "RoboPOJOGenerator" in one black color dialog showing in android studio
  3. Left top side one cursor visible on this area in paste this response
  4. Select "GSON" option in "RoboPOJOGenerator"
  5. Last click generate button after a few moments your model class is ready
August 15, 20201 minuteauthorPankaj Valani
post

Step:1 Create a new artboard

Create new artboard fill property width 1920 height 1080 resolution 75px/inch color mode RGb-8bit background white.

Step:2 Select Add a layer style

Click the lock icon to unlock the background and double click it to open click gradient overlay and the gradient bar.

Click the black & white thumbnail in the lower-left step, click the color box and pick a soft color that works with your subject.

Step:3 Set Image In artboard

Press v on your keyboard drag the photo onto the keyboard to reposition it just drag it.



Once you're happy with its size and position press enter or return next we'll septate the subject from its background by making a selection around the subject. there are many ways to do this but for this example, I'll use the quick selection tool if you're using

Step:4 Crop as a requirement

This tool as well makes its radius anywhere between 5 and 10 pixels drag the tool over the inside of your subjective selection



Step:5 Select Refine edge

Those areas to refine the selection edge click refine the edge and check smart radius that detects smooth and hard edge drags the radius a little bit to the right to adjust the size of your project make sure.

The caps lock key is off and press the right or left bracket key on your keyboard drag the brush cover all soft edges like air and press OK.



Step:6 Add Drip image

How to hook it to a new layer with a layer mask open in the background.

Ctrl-click the dripping photo to make a selection, make the original subject photoactive and press the delete icon on your keyboard click eyeball to hide the dripping pattern then be selected by pressing Ctrl+D.



Step:7 Add Brush Style

Click the new layer icon to make a new layer drag it below your subject.



Set open brush tool and brush picker take this flat seven board number 504 for brush download the splatter brush.



Step:8 Add Effect as per your Requirement

Make the subject layer active and open layer style window click drop shadow the blend mode is linear burn the color is black and the opacity is 100% the angle is 90 degrees and check the use of global light.

The distance is 5 pixels the spread is 0% and the size is 0 pixels the contour is linear and the subject is ready



August 11, 20202 minutesauthorKishan Savaliya
post

Laravel Livewire is used to build dynamic web pages that work without ajax or any javascript code. We can build dynamic components with livewire with less code and more functionalities.

I hope this basic introduction will be enough to start laravel livewire.

Now let's move to the installation steps, and I hope you already have set up your laravel project.

Install Livewire

 composer require livewire/livewire 

Include the javascript and styles (On your master blade file)

  ...      
@livewireStyles   

   ...
     @livewireScripts

Create Your Component

Here we are going to create a component to create a summation of 2 values without hitting any buttons, it will do a summation of 2 values as you type in text boxes.

Now let's create our component by hitting the following command :

php artisan make:livewire Summation

it will create 2 files as shown below:

// app/Http/Livewire/Summation/php
namespace App\Http\Livewire;

use Livewire\Component;

class Summation extends Component
{
    public function render()
    {
        return view('livewire.summation');
    } 
}

// resources/views/livewire/summation.blade.php

Include the component

Include the created component to your view where you want to show.

    ...
    @livewireStyles

    ...

    @livewireScripts

Now let's first do a change in our livewire component Summation.php

namespace App\Http\Livewire;

use Livewire\Component;

class Summation extends Component
{ 
   public $value1 = 0;
   public $value2 = 0;
   public $sum = 0;

   public function mount()
   {
      $this->sum = 0;
   }

   public function render()
   {
      $this->sum = $this->value1 + $this->value2;

      return view('livewire.summation');
   }
 }

Here we have to take 2 public properties value1, value2, and sum. and in the mounting method (which will be called when the page is loaded the first time) I have replaced the sum property value to 0.

And In the render method, I have done a summation of the 2 public property values. which will be directly accessed values of input from blade files directly here. but how ?? we will see soon.

Now let's change the livewire blade component.

  

Here we have bound all properties by using wire:model. so as we will type in input box 1 it will be directly accessed by $value1 into the component.

and the property $sum will be changed as we change the input box values.

So that's how cool livewire is. you can create different dynamic components as you need by using livewire.

Stay tuned to read more interesting posts on livewire.

August 07, 20202 minutesauthorVishal Ribdiya