Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 1 year ago.
0
Solution

You could try

$exists = DB::table('roles')->where('name', 'Moderator')->first();

if(!$exists)
   // not there

Last updated 1 year ago.
0

Perfect, thanks! Can't find that in the docs. What does it do?

Last updated 1 year ago.
0

If only need to know if that record exists you could do a count as well .

Yea you want to be looking at a different part of the API. Your not actually directly dealing with any connection.

API - Query Builder

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

OKNoah oknoah Joined 7 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.