How to Update roles in Entrust Laravel

To update the roles in Entrust is pretty simple! Have you the same question like me:) But….. 

How to assign a new role and delete the previous in Entrust Laravel?

Don’t worry, let’s check this, how we achieve this functionality

First search the user

$User=$user->find($id);

Then specify the new roles; Hint:: you can get the new roles from any form!

$NewRoles=array(role1,role2,role3);

Then passed these roles to method sync();

$User->roles()->sync($NewRoles);

This will delete all the previous roles and attach the new roles!  Cool na:)

Note:sync() accepts only array so,

You must prepare the array for this and then you can pass it to the sync() method!

OpenSSL Error: Certificate verify failed, composer error, laravel error

In my recent project,i was getting some errors like this, I google it find some solutions but I am using Mac thats why I am unable to fix it properly from those solutions.But they gave me hint to move in a direction to fix this error and after playing with it atlas I fix it.

So if you are getting this error::

[Composer\Downloader\TransportException]                                                       The file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed                       Failed to enable crypto

failed to open stream: operation failed

Here is the fix::

Step 1- First run this command

cd /usr/local/etc/openssl

Step 2- They will lead you in the openssl directory.Now run this command

ls

Result::: This command will tell you the content in this directory.

cert.pem  certs   misc     openssl.cnf   private

At this point we are interested in the file cert.pem .If you get the same result then go to the step 4.
Step 3:Run this command
brew install openssl
This will install cert.pem inside /usr/local/etc/openssl.
Step 4: Open your php.ini file and paste the below line!

openssl.cafile=/usr/local/etc/openssl/cert.pem

Note If you are on Xampp then the location of your php.in file is /Applications/XAMPP/xamppfiles/etc. More you can check your path accordingly.

And don’t forget to restart your server:)
Now run the composer, this time you will not get any error! If this post seriously help you please share this with your friends!

General error: 1215 Cannot add foreign key constraint – Laravel

You will get this error when you are creating relationship b/w two tables in your migrant file. right?

So here is a quick fix for this!

For example you have two table

user and users_address:

Schema::create('users', function (Blueprint $table) {
 $table->increments('id')->unsigned();
 $table->string('name');
 $table->string('email')->unique();
 $table->string('password', 60);
 $table->rememberToken();
 $table->timestamps();
});

Schema::create('users_address', function (Blueprint $table) {
 $table->increments('id');
 $table->integer('user_id')->unsigned();
 $table->string('user_street');
 $table->string('user_city');
 $table->timestamps();
 $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});

You will have to use ->unsigned() in both tables! what else ? Nothing!

Time to migrate!

php artisan migrate

Cheers!

One of the common error related to this, Check this post::

Base table or view not found: 1051 Unknown table

Base table or view not found: 1051 Unknown table – Laravel [Solved]

Tesux users,

To fix this ::

1- First php artisan migrate:reset rollback all your tables from the database.

2.Next go to the database check under table migrations.Whether it is empty or not.

If it is not empty >>

3.Go to the Operations and then click on Empty the table (TRUNCATE)!

<<

else

4.Now try php artisan migrate command and hope you will not get this error again

and that’s it,

Feel Free to ask if you have any questions!

Top Apps of 2015 your Android Must Have

In a clash of the two epic operating systems i.e. Android and iOS, Android has come out as a clear winner. At the end of Q4, Android had sold around about 78 million mobile phones while Apple had sold approximately 73 million handsets making Android the undisputed leader and with good reason.

Android has a very user friendly UI making it very easy and simple to learn and manoeuvre around with. Be it downloading files or transferring videos, every task can be performed in a matter of minutes and the accessibility is really nifty too.

This is why if you’re a proud Android user, go ahead and install these apps in your phone to unlock its true magic:

Dropbox For Android

This is a very handy app that lets you easily manage multitasking across various platforms be it the PC, netbook, tablet or mobile phone as you can get access to your files through this app. If you take photos they can easily be uploaded to your account as well meaning that everything you ever need is “right there” and easily within reach so you never have to feel cut out from all your important documents and photos.

BookMyShow For Android

After a tiresome week everyone needs to recharge and rewind for the coming week again. There’s no greater enjoyment than enjoying a great movie with friends and family followed by a lovely meal. Now find out what movies are running in theatres near you and easily book tickets for not just movies but plays and events too so you can skip the rush at the ticket counter and make up your mind by getting access to critics and user reviews about the movie beforehand.

Now get great deals on your next movie outing by using BookMyShow coupons exclusively given by CashKaro.com that offer you the advantage of not just great discounts but also cash back.

Vine For Android

This too is a great entertainment app that lets your inner movie freak get lose allowing you to make epic 6 second videos to show off your acting chops in front of friends. It has a simple start and stop recording button that lets you shoot great videos that you can also share on your social media to declare to the world you have arrived!

Trip Adviser For Android

If you’re planning on taking a vacation anytime soon, this is a great app that will help you shortlist your travel destination. Supported by a very active community, it gives reviews and feedback accompanied with photos from other travellers who describe how their vacation went. Now never feel confused or get tricked by travel agents by knowing exactly what you’re getting in for and you can browse through various cities across the globe. It also offers an offline map which adds to the convenience.

Get yourself an android smartphone today to enjoy these amazing apps by using Flipkart Coupons but first enjoy great discounts and cash back you will not want to miss.

Here Maps For Android

This is a great app for offline navigation so you never have to feel lost without the internet connectivity. You can easily download the maps and enable voice directions which give you a turn by turn account of where you need to go so you never get lost. Now easily find restaurants, theatres and shopping facilities anytime, anywhere on the go, around the world.

Android truly is the rightful king of smartphones and with so many options in applications be it technology, productivity, entertainment or games, keep your phone buzzing 24/7 and never miss out on any action ever again!