1. Go to this page and download the library: Download distilleries/expendable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$this->app->singleton('Distilleries\Expendable\Contracts\StateDisplayerContract', function ($app)
{
return new StateDisplayer($app['view'],$app['config']);
});
$this->app->singleton('Distilleries\Expendable\Contracts\LayoutManagerContract', function ($app)
{
return new LayoutManager($app['config']->get('expendable'), $app['view'], $app['files'], app('Distilleries\Expendable\Contracts\StateDisplayerContract'));
});
public function getIndexDatatable();
public function getDatatable();
use \Distilleries\Expendable\States\DatatableStateTrait;
public function __construct(\Address $model, AddressDatatable $datatable)
{
$this->datatable = $datatable;
$this->model = $model;
}
public function getExport();
public function postExport();
use \Distilleries\Expendable\States\ExportStateTrait;
public function __construct(\Address $model)
{
$this->model = $model;
}
$this->app->singleton('Distilleries\Expendable\Contracts\CsvExporterContract', function ($app)
{
return new CsvExporter;
});
$this->app->singleton('Distilleries\Expendable\Contracts\ExcelExporterContract', function ($app)
{
return new ExcelExporter;
});
$this->app->singleton('Distilleries\Expendable\Contracts\PdfExporterContract', function ($app)
{
return new PdfExporter;
});
public function getImport();
public function postImport();
use \Distilleries\Expendable\States\ImportStateTrait;
public function __construct(\Address $model)
{
$this->model = $model;
}
$this->app->singleton('CsvImporterContract', function ($app)
{
return new CsvImporter;
});
$this->app->singleton('XlsImporterContract', function ($app)
{
return new XlsImporter;
});
$this->app->singleton('XlsxImporterContract', function ($app)
{
return new XlsImporter;
});
public function getEdit($id);
public function postEdit();
public function getView($id);
use \Distilleries\Expendable\States\FormStateTrait;
public function __construct(\Address $model, AddressForm $form)
{
$this->form = $form;
$this->model = $model;
}
use Distilleries\DatatableBuilder\Contracts\DatatableStateContract;
use Distilleries\Expendable\Contracts\ExportStateContract;
use Distilleries\Expendable\Contracts\ImportStateContract;
use Distilleries\Expendable\States\DatatableStateTrait;
use Distilleries\Expendable\States\ExportStateTrait;
use Distilleries\Expendable\States\FormStateTrait;
use Distilleries\Expendable\States\ImportStateTrait;
use Distilleries\FormBuilder\Contracts\FormStateContract;
class BaseComponent extends ModelBaseController implements FormStateContract, DatatableStateContract, ExportStateContract, ImportStateContract {
use FormStateTrait;
use ExportStateTrait;
use DatatableStateTrait;
use ImportStateTrait;
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
public function getIndex()
{
return $this->getIndexDatatable();
}
}
use Distilleries\Expendable\Contracts\LayoutManagerContract;
use Distilleries\Expendable\Models\BaseModel;
use Illuminate\Http\Request;
class ModelBaseController extends BaseController {
/**
* @var \Distilleries\Expendable\Models\BaseModel $model
* Injected by the constructor
*/
protected $model;
// ------------------------------------------------------------------------------------------------
public function __construct(BaseModel $model, LayoutManagerContract $layoutManager)
{
parent::__construct($layoutManager);
$this->model = $model;
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
public function putDestroy(Request $request)
{
$validation = \Validator::make($request->all(), [
'id' => '
public static function getChoice();
public function scopeSearch($query, $searchQuery);
public function getAllColumnsNames();
public function scopeBetweenCreate($query, $start, $end);
public function scopeBetweenupdate($query, $start, $end);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePostsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function(Blueprint $table)
{
$table->increments('id');
$table->string('libelle');
$table->text('content')->nullable();
$table->tinyInteger('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('posts');
}
}
use Distilleries\Expendable\Models\BaseModel;
class Post extends BaseModel {
use \Distilleries\Expendable\Models\StatusTrait;
protected $fillable = [
'id',
'libelle',
'content',
'status',
];
}
namespace App\Datatables;
use Distilleries\DatatableBuilder\EloquentDatatable;
class PostDatatable extends EloquentDatatable
{
public function build()
{
$this
->add('id',null,trans('datatable.id'))
->add('libelle',null,trans('datatable.libelle'));
$this->addDefaultAction();
}
}
namespace App\Forms;
use Distilleries\FormBuilder\FormValidator;
class PostForm extends FormValidator
{
public static $rules = [];
public static $rules_update = null;
public function buildForm()
{
$this
->add('id', 'hidden')
->add('libelle', 'text')
->add('content', 'tinymce')
->add('status', 'choice');
$this->addDefaultActions();
}
}
namespace App\Forms;
use Distilleries\Expendable\Helpers\StaticLabel;
use Distilleries\FormBuilder\FormValidator;
class PostForm extends FormValidator
{
public static $rules = [
'libelle' => ' ->add('status', 'choice', [
'choices' => StaticLabel::status(),
'empty_value' => '-',
'validation' => '
namespace App\Http\Controllers\Admin;
use Distilleries\Expendable\Contracts\LayoutManagerContract;
use Distilleries\Expendable\Http\Controllers\Admin\Base\BaseComponent;
use App\Forms\PostForm;
use App\Datatables\PostDatatable;
class PostController extends BaseComponent {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
public function __construct(PostDatatable $datatable, PostForm $form, \App\Post $model, LayoutManagerContract $layoutManager)
{
parent::__construct($model, $layoutManager);
$this->datatable = $datatable;
$this->form = $form;
}
}
use \Route;
Route::get('/', 'HomeController@index');
Route::group(array('middleware' => 'auth'), function ()
{
Route::group(array('before' => 'permission', 'prefix' => config('expendable::admin_base_uri')), function ()
{
Route::controller('post', 'Admin\PostController');
});
});