2017 © Pedro Peláez
 

library laravel-status

manage status column for elqouent models

image

nagy/laravel-status

manage status column for elqouent models

  • Wednesday, February 14, 2018
  • by mohamednagy
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel-Status

manage status like moderation or anysomething else for elqouent models, (*1)

Install

$ composer install nagy/laravel-status

Using!

add the status column to your migration, (*2)

$table->tinyInteger('status')->default(0);

define the status into your elquent model, (*3)

protected static $status = [
        0 => 'pending',
        1 => 'approved',
        2 => 'rejected'
];

if you need to override the databse column or rename it, (*4)

 protected static $status_column = 'status';

include the HasStatus into your model, (*5)

use Nagy\LaravelStatus\HasStatus;

class User extends Model
{
    use HasStatus;

exmaples

laravel-status works daynamicly according to your defined status, for example for status pending then you will be able use it as isPending,setPending, onlyPending, (*6)

// check if model has status
$model->isPending();

// update model to another status
$model->setApproved();

// get only models that has status
Model::onlyPending()->get();

// or use within a query builder
Model::where('age', '>', 18)->onlyPending()->get();

The Versions

14/02 2018

dev-master

9999999-dev

manage status column for elqouent models

  Sources   Download

MIT

The Development Requires

by Avatar mohamednagy

13/02 2018

v1.0

1.0.0.0

manage status column for elqouent models

  Sources   Download

MIT

The Development Requires

by Avatar mohamednagy