mardi 3 mai 2016

Transaction () - Query Builder in laravel 5 throwing error

Trying to make an API using Transaction() for making more security for database.

Code :

try {

PostCustomer::transaction(function()
{
$CheckExistingData = PostCustomer::select('Mobile')->where('Mobile',$Mobile);   
return $CheckExistingData;
});

}
catch (Exception $e)
{

PostCustomer::rollback();
PostCustomer::commit();

}

Error :

BadMethodCallException in Builder.php line 2258:

Call to undefined method Illuminate\Database\Query\Builder::transaction()

Share your thoughts!

PostCustomer is MODEL

PostCustomer Model

class PostCustomer extends Model
{
protected $table = "Customer";
}

"Customer" is table name .



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire