Understand Basic Of Laravel Contracts

Understand Basic Of Laravel Contracts


  • Creator of Laravel, Taylor Otwell brings awesome features in Laravel 5 called Contracts.
  • Contracts are a set of interfaces which helps a developer to make code loosely coupled base OR in another term we can say Contracts are interfaces that provide core services.
  • So in common, Laravel Contracts is a wrapper of different interfaces that property of `illuminate/contracts`.
Now what are the ‘Facades’?:
Facades also interface and like a Contracts so let’s first understand what are the Facades.
  • Do they have any similarity or relationship or anything else? Let’s understand something about Facades first.
  • Facades are also static interfaces that provide access methods to the classes of service container.
  • We can use Facades `type­hint` like we already implement the route.
Route::bind('mystore', function ($id){
 return App\Store::get();
In the above code, Facades solved the contracts out of service container. But the quality of Contracts is we can define conspicuous dependencies for your classes and make your application more loosely coupled. Here Facades work fine but in some case, we want to create something extra, you need to use Contracts.
How to write?
Contracts implementation is very simple. Let’s understand the Contracts implementation with sample example:
Suppose I have a ‘StoreController’ with that I will maintain my all store list and for that, I need insert these data into the database. So what I will do, I’ll create an eloquent model ‘Store’ and bind it with a route into route.php.
After that, I will use that model ‘Store’ all CRUD operations using the resource. In between, first I check whether the user is logged in OR not? If logged in then only can able act on model CRUD otherwise not. Example code:
public function insert(Request $request)
  if (Auth::check()) {
     // If user is logged in...
From the above code, I used Facades `Auth` to check the user is logged in OR not? So here if I don’t want more decoupled state it works fine and it’s what? code with SOLID principle and here Contracts comes for the solution. For that what I do? just inject ‘Auth’ Facade through constructor:
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard as Auth;

class StoreController extends Controller
     * Display a listing of the resource.
     * @return Response
    protected $auth;
    public function __construct(Auth $auth) {//Inject `Auth` Facade...
     $this­->auth = $auth;    

    public function insert(Request $request)
As you see, when we use this line of code in our ‘StoreController’: use Illuminate\Auth\Guard as Auth;`
We actually inject an instance based on concretion, not an abstraction. Whenever we call any methods in this instance it is aware of your framework. But we need to make it completely unaware of our Framework and become loosely coupled.
To do that we just have to change one line of code in our ‘StoreController’ instead of that line of code just change `use Illuminate\Auth\Guard as Auth;` to `use Illuminate\Contracts\Auth\Guard as Auth;` and do not need to make change the store() method. This is what loosely coupled provided by Contracts.
When to use?
  • In some situation, many developers have use facades and others have use contracts and its depends on developers logic and them test and like as developer teams. contracts and facades both are used to create Laravel applications.You will look few practical differences when your class keeping responsibilities.
  • In some case, code requirement is changed to use some specific code/package/service what we do is? we need to change the controller code. but this is the correct way? No. because this will consume our time to re-code that. But is we use that contract and implement that method like service which adheres to the contract and implements those methods. Let’s understand with an example to more clarity:
I have created a `ShippingServiceContract` with methods like `getShippingRegions()`, `getShippingCost()`, `getShippingTrackStatus()`…etc like all basic methods.And create `BludartDeliveryService` which again adhere to Contract and implements those methods.
Now I will use this `ShippingServiceContract` Contract by injecting it into my controller which is called dependency injection and start using it. After a few days, I think, I don’t want to use Bludart and for replacement, I need to use some other shipping provider. So now what I need to do is, just create `SomeOtherDeliveryService` that also adhere to Contract and change binding from `SomeOtherDeliveryService` to `BludartDeliveryService` and no need to change the controller code that’s it.
For the binding between contract and implementation, we can use the service provider such as `app/Providers/AppServiceProvider.php`
The Laravel Contracts package provides a special way to extend Laravel core components explicitly and provides a stable API for developers to access the framework’s behaviour.

Hope this blog is quickly and easily guide for Laravel Contracts. Need more assistance regarding Laravel Web Development Services Contact us now!


How To Add Reminder In Ionic 2

A calendar is a very useful tool to remind you about time-specific events in your day to day life. It gives you the facility to track your events and as a result, you can use your brain in many other creative things than to keep reminding yourself about some specific events in your life.

Let’s start with integrating the reminder in your application using ionic. Below are the steps for the same.


First, add ionic native calendar Cordova plugin in your application.

ionic cordova plugin add cordova-plugin-calendar
npm install --save @ionic-native/calendar


Then import plugin in app.module.ts file.

import { Calendar } from ‘@ionic-native/calendar’

Then add createEvent() function for creating an event in the calendar and passing parameter following to ionic docs.

this.calendar.createEvent(title, location, notes, startDate,    endDate).then(
		   (msg) => { alert(msg); },
		   (err) => { alert(err); }


Then create html form for getting user calendar event data.

<form (submit)="getCalender()">
          <ion-input type="text" [(ngModel)]="title" name="title"></ion-input>

          <ion-input type="text" [(ngModel)]="notes" name="notes"></ion-input>

<ion-input type="text" [(ngModel)]="location" name="location"></ion-input>

          <ion-label>Start Date</ion-label>
<ion-datetime displayFormat="DD MMM YYYY" [(ngModel)]="startDate" name="startDate"></ion-datetime>

<ion-label>Start Time</ion-label>
<ion-datetime displayFormat="hh:mm:a" [(ngModel)]="startTime" name="startTime"></ion-datetime>

      <ion-label>End Date</ion-label>
<ion-datetime displayFormat="DD MMM YYYY" [(ngModel)]="endDate" name="endDate"></ion-datetime>

<ion-label>End Time</ion-label>
<ion-datetime displayFormat="hh:mm:a" [(ngModel)]="endTime" name="endTime"></ion-datetime>

      <button ion-button full>Submit</button>


Now add two different field for time and date in event form and marge date and time and convert javascript ISO Date() format.

var startDateTimeISO = this.buildISODate(this.startDate, this.startTime);
var enddateTimeISO = this.buildISODate(this.endDate, this.endTime);
this.calendar.requestWritePermission();	this.calendar.createEvent(this.title, this.location, this.notes, new Date(startDateTimeISO), new Date(enddateTimeISO)).then(
		        (msg) => { alert('msg '+msg); },
		        (err) => { alert('err '+err); }

buildISODate(date, time){
      var dateArray = date && date.split('-');
      var timeArray = time && time.split(':');
var normalDate = new Date(parseInt(dateArray[0]), parseInt(dateArray[1])-1, parseInt(dateArray[2]), parseInt(timeArray[0]), parseInt(timeArray[1]), 0, 0);
      return normalDate.toISOString();


Then adding event notification add ionic local notification plugin.

    ionic cordova plugin add de.appplant.cordova.plugin.local-notification
npm install –save @ionic-native/local-notifications

Then import plugin in app.module.ts file.

    import { LocalNotifications } from ‘@ionic-native/local-notifications’;

Now add notification module in your submission form function.

		   	   title: this.title,
			   text: this.notes,
			   at: new Date(startDateTimeISO),
			   led: 'FF0000',
			   sound: null


Then add Cordova platform which you prefer.

     ionic cordova platform add ios
ionic cordova platform add android

Now run your ionic application on your device.

      Ionic cordova run android –device

Hope this blog helped you to learn how to add Reminder in Ionic 2 quickly. Need more assistance regarding Hybrid App Development Contact us now!


Web Development Service Strategy Simplified!

Blog Web Development

“Rome wasn’t built in a day.” And so aren’t those ample of illustrious websites that are a combination of both – an attractive design and user-friendly features. In simpler words, the one that you love scrolling through and recommend others as a good reference. A whole lot of strategies, time and energy is put together behind building one such website. AddWeb, now having a collective experience of 150+ man-years in the field of Website Development, has churned out a few fabulous strategies to be followed while developing a website.

All great website developers go through a length of the process, in order to create a website that you’ll like spending your time behind. Though this process differs from one expert Web Development Service provider to another, it more or less remains the same. So let’s start with the checklist, AddWeb has created for you to refer. We call it the 4D-1M formula. Read on to know about it.


The fundamental step, like every other journey, is the most time taking and significant one. It’s here where maximum time and energy is spent on researching and mining out maximum data. Several questions are asked in order to gain clarity about the brand and its requirement. For instance, what is missing in the old site, what kind of language do they want to convey, target audience, et al. Study of the competitor’s website is also done in this very phase and references are gathered to be adopted at the implementation level. Both qualitative and quantitative research is done here to bring in the clarity and smoothen the further process. Because as they say, “Well begun is half done.”


Wait! Note, the job is only half done and not done yet. The core work of website development has just commenced. It is at this stage, that the blueprint of the website is created. Whatever information that has been gathered till now, is now evaluated and given structure. What features should be embedded in the site gets evaluated in here. In many cases, a mockup design is made in order to convey the whole concept to the client. To cut the story short, a basic structured is prepared of how the website will look like and function, once made.


Once the designing job is done, the project is taken further to the client for presentation. Here the final development is done. Feedback from the client is taken so that the suggestions can be implemented. If the client is adamant on a certain not-so-worthy suggestion, it’s the job of the developer to guide him to the correct path and do the best for the brand also they must be familiar with possible problems that will arise and their contingency plans must be in place as well. Once everything gets frozen here, the project goes into the deployment phase.


Halfway through the process of web development, it’s now in the deployment phase that the action happens. All the resources required for the project gets on the floor and start up with their job. And then the product is made, Website Testing is done and it’s ready to be delivered to the client. Only then, it’s ready to float on the web.


The job of Web Development never closes at the deployment stage. With all the technicalities involved in it, the client will always require technical assistance from the techies. And that’s where the one ‘M’ of 4D-1M gets into the picture. It is here that the job of maintaining the project starts and continues till the client doesn’t find some replacement of yours. And if you’re an exceptional performer and cost-effective service provider like AddWeb, then you can retain the client till the project is live on the web!

Try these treasury tricks and earn accolades and appreciations, galore!

How To Create Laravel Basic Package



Here we are discussing and learn about ‘How to create Laravel basic package’. Hope you are aware of Laravel, don’t worry if not, you can learn the basic of Laravel from Laravel official site.

I tried to explain these things in a basic term so anybody can easily implement the basic skeleton of Laravel package.

Let’s we start point by point:

Every laravel package have common folder structure like: <vendorname>/<packagename>. You can create own folder ‘packages’ at root level OR you can create your folder under ‘vendor’ folder. I’ll use ‘vendor’ folder for this explanation.

  • Create package folder under ‘vendor’ directory(Folder name format: <vendor>/<vendorname>/<packagename>)

Here,  <vendorname> could be your name OR your company name. (I.e. addweb/sample)

  • Run composer init Command at after navigating to this folder in CLI and answer the composer questions for the first setup and create src folder like vendor/addweb/sample/src

At this point, a composer will gather basic require information about your package, create composer.json and put that information into it.

  • For local testing add this package path into app root composer.json under autoload[] like:
"psr-4": {
                "App\\": "app/",
                "Addweb\\Sample\\": "vendor/addweb/sample/src"

With this step, your package will get loaded using PSR-4 autoloading but for that, we need tell composer using the command, we will check it with next step.
NOTE: Step for package submit to packagist.org. We will discuss in next blog on How to deploy our package at packagist.org.

  • Autoload this package using composer dump-autoload at root folder CLI

By run above autoload command, we actually tell Composer to autoload the all require things from composer.json and looks for all of the classes it needs to include.

Laravel official document say’s: “Service providers are the central place of all Laravel application bootstrapping. Your own application, as well as all of Laravel’s core services, are bootstrapped via service providers”.

Means that service provider is we can say the heart of the application. So lets we move forward with creating our package service provider.

  • Create service provider using PHP artisan make: provide sample service provider at root folder CLI

As per this point, your package provider is generated with the basic skeleton, you can put some extra ingredient as per your requirement. But before it we need to move this provider file into our package folder: vendor/addweb/sample/src/sampleServiceProvider.php

  • Open that moved file and change namespace like namespace addweb\sample;

By default created skeleton need to change namespace with actual one so that composer will hook our provider class using the PSR-4 autoloading standard

Now let’s register our service provider with Laravel application.

  • Register our service provider into config/app.php into providers[] array. Here we need to add our service provider into providers[] like:
'providers' => [

   * My Package Service Providers...




Now, let create and register our testing route:

  • Create new routes.php into our package src folder to handle our package used the route and register that routes.php into our service provider boot() to initiate our package used routes:

	Route::get(‘firstroute’, function(){
	echoPrint from package’;

Public function boot(){
	Include __DIR__.’/routes.php’;


Now our basic package is ready to server. Just Run PHP artisan serv at the root of your application folder and open that URL into your browser.

If you are using localhost then you can check link like localhost:8000/firstroute at your browser address bar.  Hope this helps you well, feel free to add your comments/feedbacks. Need more assistance regarding Laravel Development Service Get in touch today!

Original Posted: AddWeb Solution

Find Near By Location In Ionic 3 Using Google Map API


Google nearby location:-

Maps are always needed for finding the nearby places for our daily routine work. Here is the simple example how we can use the google map API in ionic 3 application for finding the nearby places like: hospital, restaurant, bank, airport, library, gym, etc.

Google Maps API will be used to display the maps. There are lot of things you can do with the maps API like find the nearby places, get the direction between two places etc. We will explore how to apply place recommendations and suggestions using Google Places API.


First, install the google map library using this.

npm install @types/googlemaps --save-dev

Now go to node_modules and then @types and inside that Google maps folder and add line

declare module 'googlemaps';

Now we will use the google map js library for getting informed about the places. So include the Google Map js file in the index.html file.


<script src="http://maps.google.com/maps/api/js?key=XXXXX=places"></script>

The above script needs the google map API key. Follow these steps:-

  • Go to https://console.developers.google.com
  • Create a new Google project and give an appropriate name to your project
  • Once you created a new project, it will redirect you to the API section and click the google maps Javascript API
  • Click the enable API. Then click the create credentials and click the what credentials do I need?
  • That’s all. It will give you the google map API key

Then install geolocation plugin in order to access the user location.


$ ionic cordova plugin add cordova-plugin-geolocation
$ npm install --save @ionic-native/geolocation

Now to import geolocation plugin in app.module.ts file.


import { Geolocation } from '@ionic-native/geolocation';      
     providers: [  Geolocation   ]  
     ... })


Then import the Google maps class and geolocation plugin to the home.ts file.

import { Geolocation ,GeolocationOptions } from '@ionic-native/geolocation';

import { googlemaps } from 'googlemaps';


Now use the google map places API like this.

 let service = new google.maps.places.PlacesService(this.map);

Now add this code to your home.ts file.

import { Component, NgZone, ElementRef, ViewChild } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { Geolocation ,GeolocationOptions ,Geoposition ,PositionError } from '@ionic-native/geolocation';
import { googlemaps } from 'googlemaps';

  selector: 'page-home',
  templateUrl: 'home.html'

export class HomePage {

  @ViewChild('map') mapElement: ElementRef;

  constructor(private ngZone: NgZone, private geolocation : Geolocation) { }

  ionViewDidLoad() {


    this.geolocation.getCurrentPosition().then((position) => {

this.latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

      this.mapOptions = {
        center: this.latLng,
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP

this.map = new google.maps.Map(this.mapElement.nativeElement, this.mapOptions);

    }, (err) => {
      alert('err '+err);


 /*--------------------Find Nearby Place------------------------*/ 

    this.markers = [];
    let service = new google.maps.places.PlacesService(this.map);
              location: this.latLng,
              radius: this.isKM,
              types: [this.isType]
            }, (results, status) => {
                this.callback(results, status);

  callback(results, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; i++) {

    var placeLoc = place;
    this.markers = new google.maps.Marker({
        map: this.map,
        position: place.geometry.location

    let infowindow = new google.maps.InfoWindow();

    google.maps.event.addListener(this.markers, 'click', () => {
      this.ngZone.run(() => {
        infowindow.open(this.map, this.markers);



Now Add this code to your home.html file for selecting places type and places distance find nearby places.

      Ionic Map

<ion-content padding>
<ion-label>Select Place</ion-label>
  <ion-select [(ngModel)]="isType" (ionChange)="nearbyPlace()">
  <ion-option value="">Select</ion-option>
      <ion-option value="hospital">Hospital</ion-option>
      <ion-option value="restaurant">Restaurant</ion-option>
      <ion-option value="bank">Bank</ion-option>
      <ion-option value="airport">Airport</ion-option>
      <ion-option value="library">Library</ion-option>
      <ion-option value="gym">Gym</ion-option>
    <ion-option value="atm">Atm</ion-option>
    <ion-option value="shopping_mall">Shopping Mall</ion-option>
    <ion-option value="police">Police Station</ion-option>
    <ion-option value="zoo">Zoo</ion-option>

<ion-label>Select Distance</ion-label>
  <ion-select [(ngModel)]="isKM" (ionChange)="nearbyPlace()">
  <ion-option value="500">Select</ion-option>
      <ion-option value="2000">2 KM</ion-option>
      <ion-option value="4000">4 KM</ion-option>
      <ion-option value="6000">6 KM</ion-option>
      <ion-option value="8000">8 KM</ion-option>

<div #map id="map"></div>


Hope this helps you well, feel free to add your comments/feedbacks. Need more assistance regarding Ionic App Development Get in touch today!

Book Flip 3D Animation Effect- Useful Tips From The Experts

3D Animation Effect

This is a custom 3D animated effect for Menu/ catalog/Book/brochure can be kept on the restaurant websites and as a real menu card for displaying the varieties of food available at their place. In Web Design Service this menu card can also be used in other product based websites were the varieties can be displayed as a brochure.

Animation effects

Initially,  we can only see the cover of the folded menu, on click of the ‘view Inside’ option the menu unfolds to three-panel menu card. Simple CSS3/jQuery is used for folding and unfolding of the menu-card. On clicking an item in the unfolded menu, a small description of that item is popped up. A close button is provided to close the pop-up/menu-card.


  • Browsers compatible
  • Working on touchscreen devices
  • Need not to use any external js, script, and libraries
  • SCSS & CSS both codes are available
  • Easy to use

Below is the code used to implement the concept.


<div class="main-container">
  <div id="#main-wraper" class="main-wraper">

    <!-- Menu card -->
    <div class="menu-card">
      <!-- Cover Page -->
      <div class="cover-page">
        <!-- Front Page -->
        <div class="front-page">
          <div class="front-content">
            <div class="food-menu-content">

              <!-- Add Body content -->

              <div class="view-menu">
                <a href="javascript:void(0);" class="open-btn">Look Inside &#8594</a>

        <!-- Front back Page -->
        <div class="front-page back-page">

          <!-- Add Body content -->

          <div class="side-overlay"></div>

      <!-- Middle Page -->
      <div class="middle-page">
        <div class="middle-page-content">
          <div class="middle-wraper">
            <div class="main-course-content">
              <div class="first-row">
                <a href="javascript:void(0);" class="popup">AngularJS Development Services</a>
              <div class="first-row">
                <a href="javascript:void(0);">Custom Drupal Module Development</a>
        <div class="side-overlay"></div>

      <!-- Right Page -->
      <div class="right-page">
        <!-- Right Blank Page -->
        <div class="right-blank-page"></div>

        <!-- Right Front Page -->
        <div class="right-front-page">
          <span class="close-btn"><i class="fa fa-times" aria-hidden="true"></i></span>

          <!-- Add Body content -->

          <div class="side-overlay"></div>
    <!-- Menu card end -->

    <!-- After click content -->
    <div class="after-click-content">
      <div class="inner-content">
        <span class="after-close"><i class="fa fa-times" aria-hidden="true"></i></span>
        <p>AngularJS is an open source structural framework for web application to create RICH Internet Applications. It predominates the development of dynamic and single page application and supporting MVC to develop client side applications.s</p>
    </div><!-- After click end -->


(Get CSS code from  JSFiddle demo)

  // Open btn
  jQuery('.open-btn').click(function() {
    jQuery('.back-page, .right-front-page').addClass('flip-back-page');

  // Close btn
  jQuery('.close-btn').click(function() {
    jQuery('.back-page, .right-front-page').removeClass('flip-back-page');

  // After click on inner link effect
  // Open btn
  jQuery('.popup').click(function() {
  // Close btn
  jQuery('.after-close').click(function() {


Snapshots of the 3D menu card:

3D menu card cover
3D menu card unfolding
3D menu card unfolded
3D menu card popup (onclick of an item).

Please click here for Demo. Hope this helps you well, feel free to add your comments/feedbacks. Need more assistance regarding Web Design Service Get in touch today!