*/
protected $defer = false;
- /**
- * Where the route file lives, both inside the package and in the app (if overwritten).
- *
- * @var string
- */
- public $routeFilePath = '/routes/cubist/backpack/template.php';
/**
* Perform post-registration booting of services.
public function boot()
{
// define the routes for the application
- $this->setupRoutes($this->app->router);
+ //$this->setupRoutes($this->app->router);
// // only use the Settings package if the Settings table is present in the database
// if (!\App::runningInConsole() && count(Schema::getColumnListing('settings'))) {
// }
$this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'cubist_back');
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
- }
-
- /**
- * Define the routes for the application.
- *
- * @param \Illuminate\Routing\Router $router
- *
- * @return void
- */
- public function setupRoutes(Router $router)
- {
- // by default, use the routes file provided in vendor
- $routeFilePathInUse = __DIR__ . $this->routeFilePath;
-
- // but if there's a file with the same name in routes/backpack, use that one
- if (file_exists(base_path() . $this->routeFilePath)) {
- $routeFilePathInUse = base_path() . $this->routeFilePath;
+ foreach (glob(__DIR__ . '/routes/cubist/backpack/*.php') as $filename) {
+ $this->loadRoutesFrom($filename);
}
-
- $this->loadRoutesFrom($routeFilePathInUse);
+ $this->loadViewsFrom(__FILE__ . '/resources/views','crud');
}
/**
*/
public function register()
{
- $this->app->bind('templates', function ($app) {
- return new Template($app);
- });
-
- // register their aliases
- $loader = \Illuminate\Foundation\AliasLoader::getInstance();
- $loader->alias('Template', \Backpack\Settings\app\Models\Template::class);
+// $this->app->bind('templates', function ($app) {
+// return new Template($app);
+// });
+//
+// // register their aliases
+// $loader = \Illuminate\Foundation\AliasLoader::getInstance();
+// $loader->alias('Template', \Backpack\Settings\app\Models\Template::class);
}
}
+++ /dev/null
-<?php
-
-namespace Cubist\Backpack\app\Http\Controllers;
-
-use Backpack\CRUD\app\Http\Controllers\CrudController;
-// VALIDATION
-use Cubist\Backpack\app\Http\Requests\TemplateRequest as StoreRequest;
-use Cubist\Backpack\app\Http\Requests\TemplateRequest as UpdateRequest;
-
-class TemplateCrudController extends CrudController
-{
- public function setup()
- {
- parent::setup();
-
- $this->crud->setModel("Cubist\Backpack\app\Models\Template");
- $this->crud->setEntityNameStrings(trans('cubist_back::templates.template_singular'), trans('cubist_back::templates.template_plural'));
- $this->crud->setRoute(backpack_url('template'));
- $this->crud->setColumns([
- [
- 'name' => 'name',
- 'label' => trans('cubist_back::templates.name'),
- ],
- [
- 'name' => 'description',
- 'label' => trans('cubist_back::templates.description'),
- ],
- ]);
- $this->crud->addField([
- 'name' => 'name',
- 'label' => trans('cubist_back::templates.name'),
- 'type' => 'text',
- ]);
- $this->crud->addField([
- 'name' => 'description',
- 'label' => trans('cubist_back::templates.description'),
- 'type' => 'textarea',
- ]);
- $this->crud->addField([
- 'name' => 'parent',
- 'label' => trans('cubist_back::templates.parent'),
- 'type' => 'select',
- 'entity' => 'parent',
- 'attribute' => 'name',
- 'model' => 'Cubist\Backpack\app\Models\Template',
- ]);
- $this->crud->addField([
- 'name' => 'fields',
- 'label' => trans('cubist_back::templates.field_plural'),
- 'type' => 'textarea'
- ]);
-
- $this->crud->enableAjaxTable();
- }
-
- public function store(StoreRequest $request)
- {
- return parent::storeCrud();
- }
-
-
- public function update(UpdateRequest $request)
- {
- return parent::updateCrud();
- }
-}
+++ /dev/null
-<?php
-
-namespace Cubist\Backpack\app\Http\Requests;
-
-use Illuminate\Foundation\Http\FormRequest;
-
-class TemplateRequest extends FormRequest
-{
- /**
- * Determine if the user is authorized to make this request.
- *
- * @return bool
- */
- public function authorize()
- {
- // only allow updates if the user is logged in
- return backpack_auth()->check();
- }
-
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array
- */
- public function rules()
- {
- return [
- // 'key' => 'required|min:3|max:255',
- // 'name' => 'required|min:3|max:255',
- // 'field' => 'required'
- ];
- }
-}
+++ /dev/null
-<?php
-
-namespace Cubist\Backpack\app\Models;
-
-use Backpack\CRUD\CrudTrait;
-use Illuminate\Database\Eloquent\Model;
-
-class Field extends Model
-{
- use CrudTrait;
-
- protected $table = 'cubist_fields';
- protected $fillable = ['name', 'type','options'];
-}
+++ /dev/null
-<?php
-
-namespace Cubist\Backpack\app\Models;
-
-use Backpack\CRUD\CrudTrait;
-use Illuminate\Database\Eloquent\Model;
-
-class Template extends Model
-{
- use CrudTrait;
-
- protected $table = 'cubist_templates';
- protected $fillable = ['name', 'description', 'parent', 'fields'];
-
- function parent()
- {
- return $this->belongsTo('Cubist\Backpack\app\Models\Template', 'parent');
- }
-}
--- /dev/null
+<?php
+
+namespace Cubist\Backpack\app\Templates;
+class TemplateAbstract
+{
+ public function __construct()
+ {
+ }
+
+ public function addField($field){
+ }
+}
+++ /dev/null
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-
-class CreateTemplateTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('cubist_templates', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('description')->nullable();
- $table->string('parent')->nullable();
- $table->json('fields');
- $table->timestamps();
- });
-
- Schema::create('cubist_subforms', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('description')->nullable();
- $table->string('parent')->nullable();
- $table->json('fields');
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('cubist_templates');
- Schema::drop('cubist_subforms');
- }
-}
+++ /dev/null
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-
-class CreateFieldsTable extends Migration
-{
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('cubist_fields', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('type');
- $table->json('options');
- $table->timestamps();
- });
-
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('cubist_fields');
- }
-}
--- /dev/null
+<?php
+if ($field['value'] == "")
+ return;
+$crud->route = $field['route'];
+?>
+
+<div @include('crud::inc.field_wrapper_attributes') >
+ <h3 style="margin-top:0">{!! $field['label'] !!}</h3>
+
+ <div class="array-container form-group">
+
+ <table class="table table-bordered table-striped m-b-0">
+ <thead>
+ <tr>
+ @foreach( $field['columns'] as $column )
+ <th>
+ {{ __($column['label']) }}
+ </th>
+ @endforeach
+ <th data-orderable="false">{{ trans('backpack::crud.actions') }}</th>
+ </tr>
+ </thead>
+ <tbody class="table-striped">
+ @foreach( $field['value'] as $item)
+ <tr class="array-row">
+ @foreach( $field['columns'] as $key => $column)
+ <td>
+ {!! $item->{$column['name']} !!}
+ </td>
+ @endforeach
+ <td>
+ @include('crud::buttons.update', ['entry' => $item])
+ @include('crud::buttons.delete', ['entry' => $item])
+ </td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+
+ @php
+ // Add relation entity
+ $reflection = new ReflectionClass(get_class($crud->getModel()));
+ $classname = strtolower($reflection->getShortName());
+
+ $url = "{$crud->route}/create?$classname={$crud->entry->id}";
+ @endphp
+
+ <div class="array-controls btn-group m-t-10">
+ <a href="{{ $url }}">
+ <button class="btn btn-sm btn-default" type="button"><i
+ class="fa fa-plus"></i> {{trans('backpack::crud.add')}}</button>
+ </a>
+ </div>
+
+ </div>
+</div>
<?php
-/*
-|--------------------------------------------------------------------------
-| Backpack\Settings Routes
-|--------------------------------------------------------------------------
-|
-| This file is where you may define all of the routes that are
-| handled by the Backpack\Settings package.
-|
-*/
-
-Route::group([
- 'namespace' => 'Cubist\Backpack\app\Http\Controllers',
- 'prefix' => config('backpack.base.route_prefix', 'admin'),
- 'middleware' => ['web', backpack_middleware()],
-], function () {
- CRUD::resource('template', 'TemplateCrudController');
-});
+//
+//Route::group([
+// 'namespace' => 'Cubist\Backpack\app\Http\Controllers',
+// 'prefix' => config('backpack.base.route_prefix', 'admin'),
+// 'middleware' => ['web', backpack_middleware()],
+//], function () {
+// CRUD::resource('template', 'TemplateCrudController');
+// CRUD::resource('field', 'FieldCrudController')->with(function () {
+// Route::any('field/ajax/{mode?}', 'FieldCrudController@handleAjaxRequest');
+// });
+//
+//});