Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     \App\Models\Actor::create(['nombre' => $faker->name]);
     \App\Models\Actor::create(['nombre' => $faker->name]);
     \App\Models\Actor::create(['nombre' => $faker->name]);
     \App\Models\Actor::create(['nombre' => $faker->name]);
     \App\Models\Actor::create(['nombre' => $faker->name]);
     \App\Models\Actor::create(['nombre' => $faker->name]);
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Actor::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'nombres', $this->nombres])->andFilterWhere(['like', 'apellidos', $this->apellidos]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Add a dvd to the database
  * If you're curious where a million db requests are coming from, it's here.
  * @param  array  $input
  * @return bool
  */
 public function create(array $input)
 {
     $dvd = $this->dvdInfo->firstOrCreate(['title' => $input['title'], 'description' => $input['description'], 'length' => $input['length'], 'cover_image' => $input['cover_image']]);
     $price = Price::firstOrCreate(['price_whole' => $input['price_whole'], 'price_cents' => $input['price_cents'], 'late_fee_whole' => $input['late_fee_whole'], 'late_fee_cents' => $input['late_fee_cents'], 'points' => $input['points']]);
     $input['price_id'] = $price->id;
     // Insert producers
     for ($i = 0; $i < sizeof($input['producer_name']); $i++) {
         $producer = Producer::firstOrCreate(['name' => $input['producer_name'][$i]]);
         $dvd->producers()->attach($producer);
     }
     // Insert genres
     for ($i = 0; $i < sizeof($input['genre']); $i++) {
         $genre = Genre::firstOrCreate(['genre' => $input['genre'][$i]]);
         $dvd->genres()->attach($genre);
     }
     // Insert actors
     for ($i = 0; $i < sizeof($input['actor_name']); $i++) {
         $actor = Actor::firstOrCreate(['name' => $input['actor_name'][$i]]);
         $dvd->actors()->attach($actor, ['character_name' => $input['character_name'][$i]]);
     }
     // Add new dvd stock
     $newDvds = [];
     for ($i = 0; $i < $input['stock']; $i++) {
         array_push($newDvds, new DVD($input));
     }
     $dvd->dvds()->saveMany($newDvds);
     foreach ($newDvds as $newDvd) {
         // Insert languages
         for ($i = 0; $i < sizeof($input['language_name']); $i++) {
             $language = Language::firstOrCreate(['language' => $input['language_name'][$i]]);
             $newDvd->languages()->attach($language);
         }
         // Insert subtitles
         for ($i = 0; $i < sizeof($input['subtitle_name']); $i++) {
             $subtitle = Language::firstOrCreate(['language' => $input['subtitle_name'][$i]]);
             $newDvd->subtitles()->attach($subtitle);
         }
     }
 }
Ejemplo n.º 4
0
Route::group(['prefix' => 'mantenedor'], function () {
    Route::get('pelicula', function () {
        return view('pelicula.lista');
    });
    Route::get('pelicula/crear', function () {
        JavaScript::put(['productoras' => \App\Models\Productora::all(['id', 'nombre']), 'actores' => \App\Models\Actor::all(['id', 'nombre'])]);
        return view('pelicula.crear');
    });
    Route::get('pelicula/{peliculaID}/editar', function ($peliculaID) {
        $pelicula = \App\Models\Pelicula::with('actores')->find($peliculaID);
        JavaScript::put(['pelicula' => $pelicula, 'productoras' => \App\Models\Productora::all(['id', 'nombre']), 'actores' => \App\Models\Actor::all(['id', 'nombre'])]);
        return view('pelicula.editar');
    });
    Route::get('pelicula/{peliculaID}/eliminar', function ($peliculaID) {
        $pelicula = \App\Models\Pelicula::with('actores')->find($peliculaID);
        JavaScript::put(['pelicula' => $pelicula, 'productoras' => \App\Models\Productora::all(['id', 'nombre']), 'actores' => \App\Models\Actor::all(['id', 'nombre'])]);
        return view('pelicula.eliminar');
    });
});
Route::get('img/{imgName}', 'Imagen\\ImagenController@show');
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', ['as' => 'auth/login', 'uses' => 'Auth\\AuthController@postLogin']);
Route::get('auth/logout', ['as' => 'auth/logout', 'uses' => 'Auth\\AuthController@getLogout']);
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', ['as' => 'auth/register', 'uses' => 'Auth\\AuthController@postRegister']);
Route::group(['prefix' => 'api'], function () {
    Route::get('pelicula', 'Pelicula\\PeliculaController@index');
    Route::post('pelicula', 'Pelicula\\PeliculaController@store');
    Route::post('pelicula/{peliculaID}', 'Pelicula\\PeliculaController@update');
Ejemplo n.º 5
0
 public function getNombreActor()
 {
     $actor = Actor::find()->where(['id' => $this->actorid])->one();
     return $actor->getNombreCompleto();
 }
Ejemplo n.º 6
0
use app\models\Pelicula;
use app\models\Actor;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\Actorpelicula */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="actorpelicula-form">

    <?php 
$form = ActiveForm::begin();
?>
	<?php 
echo $form->field($model, 'actorid')->dropDownList(ArrayHelper::map(Actor::find()->all(), 'id', 'nombres'), ['prompt' => 'Seleccionar actor', 'style' => 'width:300px']);
?>
    
<?php 
echo $form->field($model, 'peliculaid')->dropDownList(ArrayHelper::map(Pelicula::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccionar pelicula', 'style' => 'width:300px']);
?>
   

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
Ejemplo n.º 7
0
 /**
  * Finds the Actor model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Actor the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Actor::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActors()
 {
     return $this->hasMany(Actor::className(), ['personaid' => 'id']);
 }