Skip to content

Commit

Permalink
feat Enlaces
Browse files Browse the repository at this point in the history
  • Loading branch information
quique committed May 23, 2018
1 parent 77d26b1 commit cd7c200
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
1 change: 1 addition & 0 deletions gii/enlaceGiiantModel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"tablename":{"value":"enlace","name":"tableName"},"tableprefix":{"value":"","name":"tablePrefix"},"modelclass":{"value":"Enlace","name":"modelClass"},"ns":{"value":"app\\models","name":"ns"},"baseclass":{"value":"yii\\db\\ActiveRecord","name":"baseClass"},"db":{"value":"db","name":"db"},"generaterelations":{"value":"all","name":"generateRelations"},"generatelabelsfromcomments":{"value":"0","name":"generateLabelsFromComments"},"generatehintsfromcomments":{"value":"1","name":"generateHintsFromComments"},"generatemodelclass":{"value":"1","name":"generateModelClass"},"generatequery":{"value":"0","name":"generateQuery"},"queryns":{"value":"app\\models","name":"queryNs"},"queryclass":{"value":"","name":"queryClass"},"querybaseclass":{"value":"yii\\db\\ActiveQuery","name":"queryBaseClass"},"enablei18n":{"value":"1","name":"enableI18N"},"singularentities":{"value":"0","name":"singularEntities"},"messagecategory":{"value":"models","name":"messageCategory"},"usetranslatablebehavior":{"value":"0","name":"useTranslatableBehavior"},"languagetablename":{"value":"{{table}}_lang","name":"languageTableName"},"languagecodecolumn":{"value":"language","name":"languageCodeColumn"},"useblameablebehavior":{"value":"0","name":"useBlameableBehavior"},"createdbycolumn":{"value":"created_by","name":"createdByColumn"},"updatedbycolumn":{"value":"updated_by","name":"updatedByColumn"},"usetimestampbehavior":{"value":"0","name":"useTimestampBehavior"},"createdatcolumn":{"value":"created_at","name":"createdAtColumn"},"updatedatcolumn":{"value":"updated_at","name":"updatedAtColumn"}}
44 changes: 44 additions & 0 deletions migrations/m180523_130440_enlace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use yii\db\Migration;

/**
* Class m180523_130440_enlace
*/
class m180523_130440_enlace extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('enlace', [
'id' => $this->primaryKey(),
'nombre' => $this->string(255),
'uri' => $this->string(255),
]);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('enlace');
}

/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m180523_130440_enlace cannot be reverted.\n";
return false;
}
*/
}
34 changes: 34 additions & 0 deletions models/Enlace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace app\models;

use Yii;
use \app\models\base\Enlace as BaseEnlace;
use yii\helpers\ArrayHelper;

/**
* This is the model class for table "enlace".
*/
class Enlace extends BaseEnlace
{

public function behaviors()
{
return ArrayHelper::merge(
parent::behaviors(),
[
# custom behaviors
]
);
}

public function rules()
{
return ArrayHelper::merge(
parent::rules(),
[
# custom validation rules
]
);
}
}
55 changes: 55 additions & 0 deletions models/base/Enlace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build

namespace app\models\base;

use Yii;

/**
* This is the base-model class for table "enlace".
*
* @property integer $id
* @property string $nombre
* @property string $uri
* @property string $aliasModel
*/
abstract class Enlace extends \yii\db\ActiveRecord
{



/**
* @inheritdoc
*/
public static function tableName()
{
return 'enlace';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['nombre', 'uri'], 'string', 'max' => 255]
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('models', 'ID'),
'nombre' => Yii::t('models', 'Nombre'),
'uri' => Yii::t('models', 'Uri'),
];
}




}
11 changes: 11 additions & 0 deletions views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/* @var $content string */

use app\assets\AppAsset;
use app\models\Enlace;
use app\widgets\Alert;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
Expand All @@ -25,6 +26,10 @@
'Área de Aplicaciones. Servicio de Informática y Comunicaciones de la Universidad de Zaragoza.'
),
]);

$enlaces = array_map(function ($e) {
return ['label' => $e->nombre, 'url' => $e->uri];
}, Enlace::find()->all());
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
Expand Down Expand Up @@ -69,6 +74,12 @@
],
], */
[
'encode' => false,
'label' => '<i class="glyphicon glyphicon-link navbar-icono"></i> &nbsp;' .
Yii::t('app', 'Enlaces'),
'items' => $enlaces,
'visible' => !empty($enlaces),
], [
'encode' => false,
'label' => '<i class="glyphicon glyphicon-education navbar-icono"></i> &nbsp;' .
Yii::t('app', 'Propuestas'),
Expand Down

0 comments on commit cd7c200

Please sign in to comment.