예제 #1
0
 public function actionIndex()
 {
     $dataProviderMedia = new ActiveDataProvider(['query' => MediaType::find()]);
     $dataProviderProject = new ActiveDataProvider(['query' => ProjectType::find()]);
     $dataProviderSection = new ActiveDataProvider(['query' => SectionType::find()]);
     return $this->render('index', ['dataProviderMedia' => $dataProviderMedia, 'dataProviderProject' => $dataProviderProject, 'dataProviderSection' => $dataProviderSection]);
 }
 public function run()
 {
     $rawData = array_map('str_getcsv', file(__DIR__ . '/../data/media_types.csv'));
     $headers = array_shift($rawData);
     $items = array_map(function ($row) use($headers) {
         return array_combine($headers, $row);
     }, $rawData);
     if (!array_walk($items, function ($item) {
         MediaType::updateOrCreate(['id' => $item['id']], $item);
     })) {
         throw new Exception('There was an issue importing media types.');
     }
 }
 public function run()
 {
     if (class_exists('Faker\\Factory')) {
         $faker = Faker\Factory::create();
         $images = ['img/eusthenopteron_foordi.jpg', 'img/iridotriton_hechti.jpg', 'img/sipalocyon_sp.jpg', 'img/teinolophos_trusleri.jpg'];
         $scans = Scan::all()->all();
         $mediaTypes = MediaType::all()->all();
         foreach ($scans as $scan) {
             $count = $faker->randomDigit;
             for ($i = 1; $i <= $count; $i++) {
                 Media::create(['filePath' => '/' . $faker->word, 'fileName' => $faker->word . $faker->randomNumber(2) . '.' . $faker->randomElement(['stl', 'vgl', 'mov', 'dct']), 'fileUrl' => $faker->randomElement($images), 'scanId' => $scan->id, 'mediaTypeId' => $faker->randomElement($mediaTypes)->id]);
             }
         }
     }
 }
 public function getIndex()
 {
     return ApiResponseFactory::MakeEnvelope(MediaType::orderBy('name', 'asc')->get()->toArray());
 }
예제 #5
0
 /**
  * Finds the MediaType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MediaType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MediaType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }