/** * Return field ID given the name * @param $name the name of the field */ public static function idByName($name = NULL) { if ($name) { try { $field = Field::where('field_name', $name)->orderBy('field_name', 'asc')->firstOrFail(); return $field->id; } catch (ModelNotFoundException $e) { Log::error("The field ` {$name} ` does not exist: " . $e->getMessage()); //TODO: send email? return null; } } else { return null; } }
/** * @return \Illuminate\Routing\Route|null|string */ public function ingnoreId() { $id = $this->route('field'); $name = $this->input('name'); return Field::where(compact('id', 'name'))->exists() ? $id : ''; }