Exemplo n.º 1
0
 public function actionCreate(Requests\CreateTagRequest $request)
 {
     // Create a new model instance and populate it with the request.
     $tag = new Tag($request->all());
     // Save tag in database.
     $tag->save();
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully created a tag.');
     return redirect('tags');
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CreateTagRequest $request)
 {
     $input = $request->all();
     $tagAbbreviations = [];
     /*
      * Some events may have tags in all four categories, and while an event
      * event has to have a tag in at least one of the service, leadership,
      * or fellowship categories, an event might not have a tag in all, so
      * check and merge into one array with all tags for reduced code
      * repetition.
      */
     if (array_key_exists('service_tags', $input)) {
         $tagAbbreviations = array_merge($tagAbbreviations, $input['service_tags']);
     }
     if (array_key_exists('admin_tags', $input)) {
         $tagAbbreviations = array_merge($tagAbbreviations, $input['admin_tags']);
     }
     if (array_key_exists('social_tags', $input)) {
         $tagAbbreviations = array_merge($tagAbbreviations, $input['social_tags']);
     }
     if (array_key_exists('misc_tags', $input)) {
         $tagAbbreviations = array_merge($tagAbbreviations, $input['misc_tags']);
     }
     /*
      * Iterates through all tags selected and queries database with
      * abbreviation to find appropriate tag ID. Each tag abbreviation is
      * unique, so no need to check.
      */
     foreach ($tagAbbreviations as $abbreviation) {
         $tag = Tag::where('abbreviation', $abbreviation)->first();
         /*
          * An additional cerf_id column was added to this pivot table
          * because there may be multiple CERFs for an event and until one
          * CERF is approved (so that all other CERFs are deleted) there are
          * duplicate event_id and tag_id combinations in the pivot table.
          * In order to avoid duplicate tags being listed when looking at
          * the tags attribute, all entries are associated with a cerf_id
          * foreign key. When the tags for an event looked up, the tags for
          * the event according to only one CERF is looked up (see tags
          * relation in Event model), so no duplicates are listed since the
          * CERF form is the only way for a user to associate an event with
          * a tag.
          */
         DB::statement('insert into events_assigned_tags (event_id, tag_id, cerf_id, approved) values (' . session()->get('event_id') . ', ' . $tag->id . ', ' . session()->get('cerf_id') . ', ' . 'false);');
     }
     return redirect()->action('ActivitiesController@create');
 }
 /**
  * Update the specified Tag in storage.
  *
  * @param  int    $id
  * @param CreateTagRequest $request
  *
  * @return Response
  */
 public function update($id, CreateTagRequest $request)
 {
     /** @var Tag $tag */
     $tag = Tag::find($id);
     if (empty($tag)) {
         Flash::error('Tag not found');
         return redirect(route('admin.tags.index'));
     }
     $tag->fill($request->all());
     $tag->save();
     Flash::message('Tag updated successfully.');
     return redirect(route('admin.tags.index'));
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CreateTagRequest $request)
 {
     $data = $request->only('name');
     Tag::create($data);
     return redirect()->route('admin.' . self::URI . '.index');
 }
Exemplo n.º 5
0
 /**
  * Update the specified Tag in storage.
  *
  * @param  int    $id
  * @param CreateTagRequest $request
  *
  * @return Response
  */
 public function update($id, CreateTagRequest $request)
 {
     $tag = $this->tagRepository->findTagById($id);
     if (empty($tag)) {
         Flash::error('Tag not found');
         return redirect(route('tags.index'));
     }
     $tag = $this->tagRepository->update($tag, $request->all());
     Flash::message('Tag updated successfully.');
     return redirect(route('tags.index'));
 }