2017 © Pedro Peláez
 

library laravel-random-model

Laravel package for get a random model from database.

image

zsikta/laravel-random-model

Laravel package for get a random model from database.

  • Monday, April 11, 2016
  • by zsikta
  • Repository
  • 2 Watchers
  • 2 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel random model

Laravel package for get a random model from database., (*1)

Installation

Require this package with composer:, (*2)

composer require zsikta/laravel-random-model

Usage

Use RandomQueryable trait in your model:, (*3)

<?php

use ZsikTa\LaravelRandomModel\RandomQueryable;

class YourModel extends Model
{
    use RandomQueryable;
}

You can now use as scope:, (*4)

$singleModel = YourModel::random()->first();

$modelWithRelation = YourModel::random()->with('relation_name')->first();

Or static getter methods which return an instance:, (*5)

$model = YourModel::getRandom(); // returns an instance or null

$otherModel = YourModel::getRandomOrFail(); // returns an instance or throws exception

The Versions

11/04 2016

dev-master

9999999-dev https://github.com/zsikta/laravel-random-model

Laravel package for get a random model from database.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Tamas Zsikai

laravel model random

11/04 2016

v0.1.0

0.1.0.0 https://github.com/zsikta/laravel-random-model

Laravel package for get a random model from database.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Tamas Zsikai

laravel model random