malekbenelouafi/laravel-status

Laravel status a simple, automatic Status check for any model based on Laravel.

v1.0.0 2018-03-08 22:20 UTC

This package is not auto-updated.

Last update: 2024-10-05 19:09:30 UTC


README

License Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available Code Intelligence Status Build Status Scrutinizer Code Quality

A simple, automatic Status check for any model based on Laravel 4.* - 5.*

What are the benefits?

You can check the status of any module with sample way.

Installation

To get started, require this package

  • Via Composer
 composer require malekbenelouafi/laravel-status
  • Via composer.json file

Add the following to the require section of your projects composer.json file.

"malekbenelouafi/laravel-status": "1.*",

Run composer update to download the package

 composer update

Usage

Migrations

When using the migration you should add new columnstatus.

$table->tinyInteger('status')->comment('0: inactive; 1: active');

it's will create column status name inside of our database schema, To be ready to receive check the model.

Simply, the schema seems something like this.

Schema::create('users', function (Blueprint $table) {

  $table->increments('id');
  $table->tinyInteger('status')->comment('0: inactive; 1: active');
  ....
  ....
  $table->timestamps();
});

Models

Use this trait in any model.

To set up a model to using Uuid, simply use the HasStatus trait:

use Illuminate\Database\Eloquent\Model;
use Malekbenelouafi\LaravelStatus\HasStatus;

class ExampleModel extends Model
{
  use HasStatus;
  ....
}

Controller

When you create a new instance of a model which uses Status, our package will automatically by deafult get only active items also you can uses this scope methods:

  • ExampleModel::withInactive(): to get all element together ( all )
  • ExampleModel::withoutInactive(): to get items Without inactive element ( only active ) => by default
  • ExampleModel::onlyInactive(): to get only inactive element

Support

If you are having general issues with this package, feel free to contact me malekbelouafi@gmail.com.

If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.

If you're using this package, I'd love to hear your thoughts. Thanks!

License

The MIT License (MIT). Please see License File for more information.