Ejemplo n.º 1
0
 /**
  * Create a Destroy Link
  *
  * @return string
  */
 public function getDestroyLink()
 {
     $route = $this->getPrefix() . $this->getResourceName() . '.forcedestroy';
     if (Route::has($route)) {
         return Form::open(['route' => [$route, $this->id], 'method' => 'post', 'style' => 'display: inline;']) . Form::submit('Delete', ['class' => 'btn btn-xs btn-danger']) . Form::close();
     }
 }
 /**
  * Update an item.
  *
  * @param int|null $item
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function coreUpdate($item = null)
 {
     // Get item
     $item = $item ? $this->repository->find($item) : $this->repository->getModelInstance();
     $input = Input::all();
     // Execute hooks
     $this->onUpdate($input, $item);
     // Update attributes
     $item = $this->repository->update($item, $input);
     // Update relationships
     foreach ($input as $key => $value) {
         if (method_exists($item, $key) && $item->{$key}() instanceof BelongsToMany) {
             $item->{$key}()->sync($value);
         }
     }
     // Redirect
     $index = $this->getRoute('index');
     if (Route::has($index)) {
         return $this->getRedirect('index')->with('success', true);
     }
     return Redirect::back();
 }
Ejemplo n.º 3
0
 public function feeds()
 {
     $locale = config('app.locale');
     $feeds = collect(config('typicms.modules'))->transform(function ($properties, $module) use($locale) {
         $routeName = $locale . '.' . $module . '.feed';
         if (in_array('has_feed', $properties) && Route::has($routeName)) {
             return ['url' => route($routeName), 'title' => trans($module . '::global.feed') . ' – ' . $this->title()];
         }
     })->reject(function ($value) {
         return empty($value);
     });
     return $feeds;
 }