/**
  * Creates a step for the specified guide.
  *
  * @param GuideStepRequest $request
  * @param int|string       $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(GuideStepRequest $request, $id)
 {
     $guide = $this->guide->locate($id);
     if ($request->persist($guide, $this->guide->steps()->getRelated())) {
         flash()->success('Success!', 'Successfully added step.');
         if ($request->input('action') === 'multiple') {
             return redirect()->route('resources.guides.steps.create', [$id]);
         }
         return redirect()->route('resources.guides.show', [$id]);
     }
     flash()->error('Error!', 'There was an issue adding a step to this guide. Please try again.');
     return redirect()->route('resources.guides.create', [$id]);
 }
Beispiel #2
0
 /**
  * Catches and runs operations when a guide is deleted.
  *
  * @param Guide $guide
  */
 public function deleting(Guide $guide)
 {
     if (!$guide->deleted_at) {
         $steps = $guide->steps()->get();
         foreach ($steps as $step) {
             $step->delete();
         }
     }
 }
 /**
  * Returns a new table of the guide steps.
  *
  * @param Guide $guide
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Guide $guide)
 {
     $steps = $guide->steps()->orderBy('position');
     return $this->table->of('resources.guides', function (TableGrid $table) use($guide, $steps) {
         $table->with($steps);
         $table->layout('pages.resources.guides.steps._table');
         $table->column('move')->attributes(function (GuideStep $step) {
             return ['class' => 'sortable-handle', 'data-id' => $step->id];
         })->value(function () {
             return '<i class="fa fa-sort"></i>';
         });
         $table->column('Step', 'position')->attributes(function () {
             return ['class' => 'position'];
         });
         $table->column('title')->value(function (GuideStep $step) use($guide) {
             return link_to_route('resources.guides.steps.edit', $step->title, [$guide->slug, $step->getPosition()]);
         });
         $table->column('description')->value(function (GuideStep $step) {
             return $step->description ? str_limit($step->description, 25) : '<em>None</em>';
         });
         $table->column('delete')->value(function (GuideStep $step) use($guide) {
             $attribues = ['class' => 'btn btn-sm btn-danger', 'data-title' => 'Delete Step?', 'data-message' => 'Are you sure you want to delete this step?', 'data-post' => 'DELETE'];
             return link_to_route('resources.guides.steps.destroy', 'Delete', [$guide->slug, $step->getPosition()], $attribues);
         });
     });
 }