domingo, 18 de junio de 2017
Actualizar composer yii2
sudo composer global require fxp/composer-asset-plugin:~1.3@dev
martes, 23 de mayo de 2017
Poner un estilo a GridView
[
'attribute'=>'estado_baja',
'value' => 'estadoBaja.nombre',
'contentOptions' => function($model)
{
return ['style' => 'color:' . $model->estadoBaja->color];
},
'filter' => yii\helpers\ArrayHelper::map(app\modules\admin\models\EstadoBaja::find()->orderBy('nombre')->asArray()->all(),'id','nombre')
],
'attribute'=>'estado_baja',
'value' => 'estadoBaja.nombre',
'contentOptions' => function($model)
{
return ['style' => 'color:' . $model->estadoBaja->color];
},
'filter' => yii\helpers\ArrayHelper::map(app\modules\admin\models\EstadoBaja::find()->orderBy('nombre')->asArray()->all(),'id','nombre')
],
miércoles, 17 de mayo de 2017
Escenarios en Yii2
Se crea el escenario en el modelo en la funcion rules
[['usuario', 'id_area', 'id_piso'], 'required', 'on'=>'upuser'],
y en el controlador
si es update
$model = $this->findModel($id);
$model->scenario = 'upuser';
Si es insert
$model = new InvEquipos(['scenario'=>'upuser']);
[['usuario', 'id_area', 'id_piso'], 'required', 'on'=>'upuser'],
y en el controlador
si es update
$model = $this->findModel($id);
$model->scenario = 'upuser';
Si es insert
$model = new InvEquipos(['scenario'=>'upuser']);
martes, 25 de abril de 2017
Crear relaciones entre modelos
use app\modules\soporte\models\CatAntiguedad;
public function getCatAntiguedad()
{
return $this->hasOne(CatAntiguedad::className(),['id'=>'clasif']);
}
Para mandar llamarla relacion es por medio
<?= $model->catAntiguedad->nombre ?>
public function getCatAntiguedad()
{
return $this->hasOne(CatAntiguedad::className(),['id'=>'clasif']);
}
Para mandar llamarla relacion es por medio
<?= $model->catAntiguedad->nombre ?>
Dropdownlist Dependientes yii2
<div class="form-group">
<label for="curl" class="control-label col-lg-2">Marca</label>
<div class="col-lg-4">
<?= $form->field($model, 'marca', ['inputOptions'=>[ 'class'=>'form-control', 'placeholder' => 'tipo'] ] )->dropDownList(ArrayHelper::map(app\modules\soporte\models\CatMarca::find()->orderBy(['id'=>SORT_ASC])->all(),'id','nombre'),
[
'prompt'=>Yii::t('app', '--- Selecciona Marca ---'),
'onchange'=>'
$.post( "'.Yii::$app->urlManager->createUrl('soporte/inv-equipos/modelos?id=').'"+$(this).val(), function( data ) {
$( "select#invequipos-modelo" ).html( data );
});
'])->label(false); ?>
</div>
</div>
<div class="form-group">
<label for="ccomment" class="control-label col-lg-1">Modelo</label>
<div class="col-lg-4">
<?= $form->field($model, 'modelo', ['inputOptions'=>[ 'class'=>'form-control', 'placeholder' => 'modelo'] ] )->dropDownList(ArrayHelper::map(app\modules\soporte\models\CatModelo::find()->orderBy(['id'=>SORT_ASC])->all(),'id','modelo'),['prompt'=>Yii::t('app', '--- Selecciona modelo ---')])->label(false); ?>
</div>
</div>
----Action--
public function actionModelos($id)
{
$cuentaModelos = CatModelo::find()->where(['id'=>$id])->count();
$modelos = CatModelo::find()->where(['id'=>$id])->all();
if ($cuentaModelos > 0) {
foreach ($modelos as $key => $value) {
echo "<option value=". $value->id . ">". $value->modelo. "</option>";
}
}else{
echo "<option>-</option>";
}
}
<label for="curl" class="control-label col-lg-2">Marca</label>
<div class="col-lg-4">
<?= $form->field($model, 'marca', ['inputOptions'=>[ 'class'=>'form-control', 'placeholder' => 'tipo'] ] )->dropDownList(ArrayHelper::map(app\modules\soporte\models\CatMarca::find()->orderBy(['id'=>SORT_ASC])->all(),'id','nombre'),
[
'prompt'=>Yii::t('app', '--- Selecciona Marca ---'),
'onchange'=>'
$.post( "'.Yii::$app->urlManager->createUrl('soporte/inv-equipos/modelos?id=').'"+$(this).val(), function( data ) {
$( "select#invequipos-modelo" ).html( data );
});
'])->label(false); ?>
</div>
</div>
<div class="form-group">
<label for="ccomment" class="control-label col-lg-1">Modelo</label>
<div class="col-lg-4">
<?= $form->field($model, 'modelo', ['inputOptions'=>[ 'class'=>'form-control', 'placeholder' => 'modelo'] ] )->dropDownList(ArrayHelper::map(app\modules\soporte\models\CatModelo::find()->orderBy(['id'=>SORT_ASC])->all(),'id','modelo'),['prompt'=>Yii::t('app', '--- Selecciona modelo ---')])->label(false); ?>
</div>
</div>
----Action--
public function actionModelos($id)
{
$cuentaModelos = CatModelo::find()->where(['id'=>$id])->count();
$modelos = CatModelo::find()->where(['id'=>$id])->all();
if ($cuentaModelos > 0) {
foreach ($modelos as $key => $value) {
echo "<option value=". $value->id . ">". $value->modelo. "</option>";
}
}else{
echo "<option>-</option>";
}
}
jueves, 15 de diciembre de 2016
error [ReflectionException] Class DatabaseSeeder does not exist
al ejecutar cesar@sisweb:/var/www/html/contact_manager$ php artisan db:seed
marca
Just wondering before "[ReflectionException] Class DatabaseSeeder does not exist" it was [ReflectionException] Class database\seeds\userTableSeeder does not exist
after trying all suggested putting namespace in it showed in the links and several call of commands "composer dump-autoload" and "php artisan clear-compiled" it suddenly become the Class DatabaseSeeder.
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
//Eloquent::unguard();
$this->call(GroupTableSeeder::class);
$this->call(ContactTableSeeder::class);
}
}
<?php
use Illuminate\Database\Seeder;
class GroupTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::statement('SET FOREIGN_KEY_CHECKS=0');
DB::table('groups')->truncate();
$groups = [
['id' => 1, 'name' => 'Family', 'created_at' => new DateTime, 'updated_at' => new DateTime],
['id' => 2, 'name' => 'Friends', 'created_at' => new DateTime, 'updated_at' => new DateTime],
['id' => 3, 'name' => 'Clients', 'created_at' => new DateTime, 'updated_at' => new DateTime],
];
DB::table('groups')->insert($groups);
}
}
<?php
use Illuminate\Database\Seeder;
use Faker\Factory as Faker;
class ContactTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::table('contacts')->truncate();
$faker = Faker::create();
$contacts = [];
foreach (range(1,20) as $index) {
$contacts[]= [
'name' => $faker->name,
'email' => $faker->email,
'phone' => $faker->phoneNumber,
'address' => "{$faker->streetName} {$faker->postcode} {$faker->city}",
'company' => $faker->company,
'created_at' => new DateTime,
'updated_at' => new DateTime,
];
}
DB::table('contacts')->insert($contacts);
}
}
lunes, 5 de diciembre de 2016
Intalacion de Teamviwer cuando no te jalan las dependencias
sudo dpkg --force-depends -i teamviewer_linux_x64.debInstalacion de teamviwer
Suscribirse a:
Entradas (Atom)