<?php
namespace App\Http\Controllers\Cms;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Auth;
use App\Autoform;
class CmsController extends Controller
{
use AuthorizesRequests, DispatchesJobs;
function __construct()
{
parent::__construct();
}
public function index(Request $request)
{
$this->setTemplate('cms.pages.home.index');
}
public function form(Request $request, $model, $id = 'add')
{
if($id == 'add')
{
$id = null;
}
$modelAction = $model;
if(!is_null($id))
{
$modelAction = $modelAction.'/'.$id;
}
$this->addJavaScriptData('modelName', $modelAction);
$model = $this->getModel($model);
$fields = Autoform::loadFromModel($model, 'form_'.$model->modelName, 'POST', 'cms/api/'.$model->modelName, $id);
$this->addModules('form');
$this->addData('model', $model);
$this->addData('form', $fields);
$this->addData('modelName', $model->modelName);
$this->setPageTitle('Listar '.$model->modelName);
$this->setTemplate('cms.pages.generic.form');
}
public function listing(Request $request, $model)
{
$this->addJavaScriptData('modelName', $model);
$model = $this->getModel($model);
$this->addModules('list');
$fields = Autoform::loadFromModel($model, 'form_'.$model->modelName, 'POST', 'cms/api/'.$model->modelName);
$this->addData('model', $model);
$this->addData('modelName', $model->modelName);
$this->addData('list', $model->fields);
$this->setPageTitle('Salvar '.$model->modelName);
$this->setTemplate('cms.pages.generic.list');
}
}
|