Git Product home page Git Product logo

core-utilities's Introduction

Core Utilities

This package includes some useful utilities for Laravel 5.5+ to extend some functionality and prepare project for other related packages


Currently included:

  • class AbstractTypes - Extend this class and add your constants to use them later easily.

Usage

class Gender extends AbstractTypes {
    const MALE = 1;
    const FEMALE = 2;
}
    print_r(Gender::MALE); // Output: 1
    print_r(Gender::FEMALE); // Output: 2
    print_r(Gender::all()); // Output: '1,2'
    print_r(Gender::all('json')); // Output: '{"1":"translated.male","2":"translated.female"}'
    // You can also pass second parameter false, to not translate the values
    print_r(Gender::all('json', false)); // Output: '{"1":"MALE","2":"FEMALE"}'
    print_r(Gender::all('array')); // Output: ["MALE" => 1, "FEMALE" => 2]

  • class AppEngineCron - Just a middleware to filter and allow only requests from Google AppEngine's CRON

Usage

Just add to routes you need to filter


  • class ForceSSL - Middleware to convert HTTP reuests to HTTPS if set in configuration

Usage

Edit protocol parameter in configuration file and add to routes you need to convert


  • class Handler - Exception to RESTful error messages converter

Usage

Extend your App/Exceptions/Handler from this class, and you will get all exceptions prettified for RESTful API


  • class Model - This class extends from native Eloquent Model and adds some useful features like camelCase attributes, translatable attributes and optional and configurable attribute sanitization

Usage

Extend all your model's from this one instead of native Illuminate\Database\Eloquent\Model and you will get them all automatically


  • trait HasParams - You can use this trait in all your models which have params attribute in database

DO NOT FORGET to cast your params attribute as array before using this trait


  • trait HasIcon - You can use this trait in all your models which have icon. This will add $model->saveIcon($image); and $model->deleteIcon(); methods.

DO NOT FORGET to add icon column to your model's table before using this trait


  • class Storage - You can use it as a factory for your storage

Usage

use Ptuchik\CoreUtilities\Helpers\Storage;

$storage = new Storage(); // Pass true as the only parameter if you need to initialize your public storage

// ... after initialization you can use $storage variable as regular Filesystem Adapter. like:

$storage->get($path);
$storage->put($path);

// ...etc...

core-utilities's People

Contributors

ptuchik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.