Git Product home page Git Product logo

laravel-sandbox's People

Contributors

mesour avatar

Watchers

 avatar  avatar

Forkers

spernica

laravel-sandbox's Issues

Example of the Laravel view composer

Dedicated source that extends that class.

<?php namespace Modules\Core\Http\ViewComposers\Admin\Site;

use Modules\Core\Entities\Site as SiteEntity;
use LaravelDoctrine\ORM\Facades\EntityManager;
use Modules\Core\Mesour\DataGrid\Sources\DoctrineGridSource;

class DataGridSource extends DoctrineGridSource {

    public function __construct() {

        $qb = EntityManager::createQueryBuilder();
        $qb
            ->select('s','c')
            ->from(SiteEntity::class, 's')
            ->join('s.creator','c');

        parent::__construct(SiteEntity::class,'id',$qb);

    }

}

Example of the Laravel view composer that puts it all together.

<?php namespace Modules\Core\Http\ViewComposers\Admin\Site;

use Illuminate\View\View;
use Doctrine\ORM\EntityManagerInterface;
use Mesour\Bridges\Laravel\ApplicationManager;
use Mesour\UI\DataGrid;

class DataGridComposer {

    protected $uiApp;

    public function __construct(ApplicationManager $uiApp) {

        $this->uiApp = $uiApp;

    }

    public function compose(View $view) {

        $source = new DataGridSource();

        $grid = new DataGrid('sites',$this->uiApp->getApplication());
        $grid->setSource($source);
        $grid->enablePager(10);
        $grid->enableFilter(true);

        $grid->addText('id','ID');
        $grid->addText('machineName','Machine Name');

        $grid->addText('creator','Creator')->setFiltering(false)->setOrdering(false)->setCallback(function($col,$site) {
            return $site['creator']['email'];
        });

        $grid->addDate('createdAt','Created');
        $grid->addDate('updatedAt','Updated');

        $view->with('grid',$grid);

    }

}

This might be a good recipe for others who also don't want to define a strategy on every entity for array conversion.

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.