/** * Run the database seeds. * * @return void */ public function run() { Profession::create(['name' => 'Back-End Developer']); Profession::create(['name' => 'Front-End Developer']); Profession::create(['name' => 'Full Stack Developer']); Profession::create(['name' => 'Designer']); Profession::create(['name' => 'Other']); }
/** * Authorize the upload action of a picture album * see the route list for details * * @param $model * @param $model_id * @param $id * * @return bool */ private function _authorize($model, $model_id, $id) { switch ($model) { case 'user': if ($id != 'new') { $this->album = Album::where('id', $id)->first(); session(['album_id' => null]); } else { if (session('album_id') && session('album_id') != null) { $this->album = Album::where('id', session('album_id'))->first(); } else { $this->makeNewAlbum(); Auth::user()->albums()->save($this->album); $this->album->update(['user_id' => Auth::id()]); } } break; case 'article': $this->article = Article::whereId($id)->first(); if (!($this->album = Album::where('albumable_id', $id)->get()->first())) { $this->makeNewAlbum(); $this->article->albums()->save($this->album); } break; case 'profession': $this->profession = Profession::whereId($id)->first(); if (!($this->album = Album::where('albumable_id', $id)->get()->first())) { $this->makeNewAlbum(); $this->profession->albums()->save($this->album); } break; case 'site': $this->site = Site::whereId($model_id)->first(); if (!($this->album = Album::where('id', $id)->first())) { if (!$this->site->albums->last()) { $this->makeNewAlbum(); $this->site->albums()->save($this->site); } } break; case 'classified': $this->classified = Classified::whereId($id)->first(); if (!($this->classified = Album::where('albumable_id', $id)->get()->first())) { $this->makeNewAlbum(); $this->classified->albums()->save($this->album); } break; } //session(['album_id' => $this->album->id]); return true; }
public function getProfessionIdOptions() { return Profession::lists('name', 'id')->toArray(); }
public function name($id) { $profession = Profession::find($id); return response()->json(trim($profession->name), 200); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $profession = Profession::findOrFail($id); $profession->delete(); }
/** * Return the favorites of a certain model or table, leave the data as is under $model->settings['favorites'] * * @param $model * @param $data * * @return object|false */ static function getFavoritesByModel($model, $data) { if (!isset($data[$model])) { return false; } $data = array_keys($data[$model]); switch ($model) { case 'articles': return Article::whereIn('id', $data)->get(); case 'sites': return Site::whereIn('id', $data)->get(); case 'professions': return Profession::whereIn('id', $data)->get(); case 'classifieds': return Classified::whereIn('id', $data)->get(); case 'albums': return Album::whereIn('id', $data)->get(); case 'agoda': return AgodaHotel::whereIn('hotel_id', $data)->get(); default: return false; } }