/**
  * Returns a new table of inquiry categories.
  *
  * @param \Illuminate\Database\Eloquent\Builder|Category $category
  * @param Inquiry                                        $inquiry
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table($category, Inquiry $inquiry)
 {
     if ($category->exists) {
         // If the category exists we're looking to display it's children.
         $category = $category->children();
     } else {
         // Otherwise we're displaying root nodes.
         $category = $category->whereIsRoot()->whereBelongsTo($inquiry->getTable());
     }
     return $this->table->of('inquiries.categories', function (TableGrid $table) use($category) {
         $table->with($category)->paginate($this->perPage);
         $table->layout('pages.categories._table');
         $table->column('name', function (Column $column) {
             $column->value = function (Category $category) {
                 return link_to_route('inquiries.categories.index', $category->name, [$category->id]);
             };
         });
         $table->column('sub-categories', function (Column $column) {
             $column->value = function (Category $category) {
                 return $category->children()->count();
             };
         });
         $table->column('delete', function (Column $column) {
             $column->value = function (Category $category) {
                 $route = 'inquiries.categories.destroy';
                 return link_to_route($route, 'Delete', [$category->id], ['data-post' => 'DELETE', 'data-title' => 'Delete Category?', 'data-message' => 'Are you sure you want to delete this category? All child categories will be destroyed.', 'class' => 'btn btn-xs btn-danger']);
             };
         });
     });
 }
Esempio n. 2
0
 /**
  * Creates a new inquiry.
  * @param int|string     $categoryId
  * @param InquiryRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store($categoryId, InquiryRequest $request)
 {
     $category = $this->category->whereBelongsTo($this->inquiry->getTable())->findOrFail($categoryId);
     $inquiry = $this->inquiry->newInstance();
     if ($this->dispatch(new Store($request, $inquiry, $category))) {
         flash()->success('Success!', 'Successfully created request.');
         return redirect()->route('inquiries.index');
     }
     flash()->error('Error!', 'There was an issue creating a request. Please try again.');
     return redirect()->route('inquiries.create');
 }
Esempio n. 3
0
 /**
  * Returns a new table of all categories.
  *
  * @param Inquiry  $inquiry
  * @param Category $category
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function tableCategories(Inquiry $inquiry, Category $category)
 {
     if ($category->exists) {
         // If the category exists we're looking to display it's children.
         $category = $category->children();
     } else {
         // Otherwise we're displaying root nodes.
         $category = $category->whereIsRoot()->whereBelongsTo($inquiry->getTable());
     }
     return $this->table->of('inquiries.categories', function (TableGrid $table) use($category) {
         $table->with($category)->paginate($this->perPage);
         $table->layout('pages.categories._table');
         $table->column('name', function (Column $column) {
             $column->value = function (Category $category) {
                 return link_to_route('inquiries.start', $category->name, [$category->id]);
             };
         });
         $table->column('select', function (Column $column) {
             $column->value = function (Category $category) {
                 $route = 'inquiries.create';
                 return link_to_route($route, 'Select This Category', [$category->id], ['class' => 'btn btn-success btn-sm']);
             };
         });
         $table->column('sub-categories', function (Column $column) {
             $column->headers = ['class' => 'hidden-xs'];
             $column->value = function (Category $category) {
                 return $category->children()->count();
             };
             $column->attributes = function ($row) {
                 return ['class' => 'hidden-xs'];
             };
         });
     });
 }