Giter Site home page Giter Site logo

laravel-rapids's Introduction

alt tag

The rapid development made with laravel.

This library is intended for those developers who like to make applications as fast as possible.

Requirements

  • PHP >= 7.0.0
  • Bootstrap on your project

Installation

Add Rapids service provider Laravel\Rapids\RapidsServiceProvider::class, to your app.php config in Laravel.

Usage

<?php
$data_grid = new DataGrid(Post::query());
$data_grid->add('id', 'id');
$data_grid->add('title', 'Name');
$data_grid->setActions('/post/edit', 'modify|delete');

$grid = Widget::load($data_grid);

return view('grid', compact('grid'));

In your view:

{!! $grid !!}

This will generate a simple datagrid with modify/delete options.

Load any widget

Remember that to load any widget you're gonna need to execute $widget_render = Widget::load($widget);and will return the render of that widget. You only need to pass to blade as raw format {!! $widget !!}.

Elements

In order to ease the usability of this tool we've created some widgets for you. Just to use on any place.

DataGrid

The DataGrid is the bridge head of the computer development. You're gonna need it for everything. So lets take a look to the options that Rapids brings.

Startup

$data_grid = new DataGrid(Post::query()); Start your DataGrid within an Eloquent model query

Adding new field to the table

$data_grid->add('title', 'Title'); When you need to add a new field.

If you need that this field shows orderBy buttons. Set to true the third optional parameter.

Actions (Edit/Show/Delete)

$data_grid->setActions('/post/edit', 'modify|delete'); This will add the action buttons in your DataGrid. Available options are "modify", "delete", "show"

Value transformations

Imagine the common case to have a price value over 50 to be painted as yellow.

$grid_widget->add('title', 'Title')->transform('price', 'Pricing', function($value){
    $result = $value;
    if($value > 50){
        $result = '<span style="background-color: yellow;">'.$value.'</span>';
    }
    return $result;
});

You can obviously make your own widget instead of adding raw html to the PHP code. Just pass any rendered string as result of the callback.

Row transformations

Sometimes you need to set some classes to the entire row. Use this type of transformation to do so.

Relations

Obviously you will need to add some relations to the table. The best way to achieve this is using a transformation. So for example:

$grid_widget->addTransformation('categories', 'Categories', function($value){
    return $value->implode('name', ', ');
});

setActions

DataForm

public function create()
{
    $data_form = new DataForm(new Book(), '/admin/book');
    $data_form->add('title', 'Book title');
    $data_form->add('categories.name', 'Categories', Cell::TYPE_CHECKBOXGROUP);
    $create = Widget::load($data_form);
    return view('admin/book/create', compact('create'));
}
public function store()
{
    $data_form = new DataForm(new Book(), '/admin/book');
    $data_form->setRequest($request);
    $data_form->request('title');
    $data_form->request('token');

    return $data_form->operate();
}

Idea

The idea comes from other's people libraries that are really good. And the need to have a well written code base just to mess with.

laravel-rapids's People

Contributors

alrik11es avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.