jeudi 19 janvier 2017

Laravel FirstOrCreate or something else

I would like to limit only one entry in the table and I am not sure how to do it.

I've read about firstOrCreate but in my model I have:

use Illuminate\Database\Eloquent\Model;
class Ad extends Model
{
   protected $fillable = [
     'title',
     'description',
     'image'
   ];
}

Basically I want to use it for some advertising box on website but only one will be visible. So I don't want to loop over and show for example last one.

How can I achieve this?

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iEUs04
via IFTTT

Aucun commentaire:

Enregistrer un commentaire