Exemple #1
0
 public static function getTypes()
 {
     self::$types = MediaType::orderBy('name')->lists('name', 'id');
     return static::$types;
 }
 /**
  * Check whether the submitted type ID exists, or creates a new type and
  * then returns the id.
  * 
  * @param string $type_id
  * @return integer
  */
 protected function checkType($type_id)
 {
     // if the submitted type id is an integer, check it exists and return it.
     // If it doesn't exist, return false (don't let people set up integer types)
     if (is_numeric($type_id)) {
         $id = MediaType::find($type_id);
         if ($id) {
             return $id;
         }
         return false;
     }
     // if the submitted type id is a string, create a new type in the DB and then
     // return the id of the newly created record for association with the submitted
     // media.
     $id = MediaType::create(['name' => $type_id, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     return $id->id;
 }