Friday, July 29, 2016

IE Blocking iFrame Cookies

 IE Blocking iFrame Cookies :

 Today we will discuss about "IE Blocking iFrame Cookies".

I have faced a problem in my applications not running correctly from inside an iFrame. I tried it out and it looked like everything worked great in Safari and Firefox but not IE6 or IE7. It took me a few failed attempts to fix it before I decided it must be a session problem. After firing up a packet sniffer it became obvious the cookie with the session ID was not being passed.

The problem lies with a W3C standard called Platform for Privacy Preferences or P3P for short. You can read all about the boring stuff via the link or else just install the P3P Compact Policy header below. This will allow Internet Explorer to accept your third-party cookie. You will need to send the header on every page that sets a cookie.


PHP:

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

Thanks

Friday, July 22, 2016

How to implement shopping cart in laravel 5

How to implement shopping cart in laravel 5:

For implement shopping cart in your application we have to follow following steps:

1. In your composer.json file write the following code in require:


"gloudemans/shoppingcart": "^2.1",

then run command composer update.

2. In config/app.php write the following code.

In providers:
\Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class

In aliases:
'Cart'            => \Gloudemans\Shoppingcart\Facades\Cart::class,

Now we can use cart in our applications

for add product in cart:
 Cart::add('293ad', 'Product 1', 1, 9.99);

 Here first parms is product id, 2nd is name of product, 3rd quantity and 4th is price of product

for update:
Cart::update($rowId, 2);

Here $rowId is a unique id product wise which is generate automatically.
2nd params is the quantity, which we want to increase.

for remove:
Cart::remove($rowId);

for check the cart:
Cart::content();

for destroy cart:
Cart::destroy();

for total in cart:
Cart::total();

for count in cart:
Cart::count();

Thanks

Friday, July 8, 2016

Updating Column Types with Laravel's Schema Builder

Laravel makes database migrations very easy with its Schema Builder. It has a lot of built-in methods to add tables, columns, indexes, etc. However, it's easy to forget that you can do so much more with just plain old SQL queries.

I needed to change the type of a column from VARCHAR to TEXT. Here's what I ran in a migration file:


public function up()
{
    DB::statement('ALTER TABLE flavours MODIFY COLUMN description TEXT');
}

public function down()
{
    DB::statement('ALTER TABLE flavours MODIFY COLUMN description VARCHAR(255)');
}  


I think this will make you little help.

Thanks.

Friday, June 24, 2016

Angular 2 Beginning using Component

Angular 2 Beginning using Component:

In beginning, open app.component.ts file and write the code in it.

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: `        <h1 (click)="onSelect()">Ashish Ginotra's</h1>        <p>Hello World!</p>        <h1 *ngIf="showDetail === true">This is {{contact.lastname}}</h1>        <input [(ngModel)]="contact.lastname" type="text">    `,
})
export class AppComponent {
    public contact = {firstname:"Ashish",lastname:"Ginotra"};
        public showDetail = false;
    onSelect(){
        this.showDetail = true;
    }
}

Add this code in your file and run

npm strat.

This will show the output.

Thanks

Friday, June 17, 2016

Token Mismatch error on login page Laravel 5

Token Mismatch error on login page Laravel 5:

Sometimes we noticed on the login page of Laravel 5, when we leave this page for sometimes and then click on login button, then it shows token mismatch error.

This is because session time of laravel has been expired and current token for that page do not match the actual page.

For prevent this kind of error, we have to handle it.

Goto this file :  app/Exceptions/Handler.php

and add this code in render function.

    public function render($request, Exception $e)
    {
        if ($e instanceof \Illuminate\Session\TokenMismatchException) {
            return redirect()->guest('auth/login');
        }
        return parent::render($request, $e);
    }


Thanks

Friday, June 10, 2016

Resize image in Laravel 5

Resize image in Laravel 5:

For resizing image in laravel:

Firstly we have to install a package. For this open your composer.json and write this code in require.

"intervention/image": "dev-master"

then run composer update

In config/app.php write this code in aliases

'Image'     => Intervention\Image\Facades\Image::class,

and this in providers

Intervention\Image\ImageServiceProvider::class,

Now go to your controller & use this.

use Intervention\Image\Facades\Image;

 Now go to your method and write this code

$dirName = 'path/of/image';
$img = Image::make($dirName . "/background.jpg")->resize(720, 1280);
$img->save($dirName . "/background.jpg");


Thanks

Friday, June 3, 2016

How to delete latest file in folder in php

How to delete latest file in folder in php:

For delete the latest file in php we have to use following code.

           $filePath = 'path/of/folder';
            $files = glob($filePath . '/*.*');
            array_multisort(
                array_map('filemtime', $files),
                SORT_NUMERIC,
                SORT_ASC,
                $files
            );
            exec("rm -rf " . $files[0]);


Thanks