Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

You could try

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

if(!$exists)
   // not there

Last updated 2 years ago.
0

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

Last updated 2 years 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 2 years 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.