getRouteKey(); } public function title() { if ($this->title != '') { return $this->title; } if ($this->name != '') { return $this->name; } return 'None'; } public function toArray($request) { return [ 'id' => $this->getRouteKey(), 'title' => $this->title(), 'name' => $this->name, 'email' => $this->email, 'color' => $this->color, 'date' => $this->date, 'datetime' => $this->datetime, 'file' => $this->file, 'files' => $this->files, 'image' => $this->image, 'images' => $this->images, 'month' => $this->month, 'password' => $this->password, 'range' => $this->range, 'search' => $this->search, 'tel' => $this->tel, 'time' => $this->time, 'url' => $this->url, 'week' => $this->week, 'date_picker' => $this->date_picker, 'time_picker' => $this->time_picker, 'date_time_picker' => $this->date_time_picker, 'radios' => $this->radios, 'checkboxes' => $this->checkboxes, 'switch' => $this->switch, 'select' => $this->select, 'model_select' => $this->model_select, 'tinyints' => $this->tinyints, 'smallints' => $this->smallints, 'mediumints' => $this->mediumints, 'ints' => $this->ints, 'bigints' => $this->bigints, 'decimals' => $this->decimals, 'floats' => $this->floats, 'doubles' => $this->doubles, 'reals' => $this->reals, 'bits' => $this->bits, 'booleans' => $this->booleans, 'dates' => $this->dates, 'datetimes' => $this->datetimes, 'timestamps' => $this->timestamps, 'times' => $this->times, 'years' => $this->years, 'chars' => $this->chars, 'varchars' => $this->varchars, 'tinytexts' => $this->tinytexts, 'texts' => $this->texts, 'mediumtexts' => $this->mediumtexts, 'longtexts' => $this->longtexts, 'binarys' => $this->binarys, 'varbinarys' => $this->varbinarys, 'tinyblobs' => $this->tinyblobs, 'mediumblobs' => $this->mediumblobs, 'blobs' => $this->blobs, 'longblobs' => $this->longblobs, 'enums' => $this->enums, 'sets' => $this->sets, 'slug' => $this->slug, 'status' => $this->status, 'user_id' => $this->user_id, 'user_type' => $this->user_type, 'upload_folder' => $this->upload_folder, 'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null, 'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null, 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), ], ]; } /** * Get additional data that should be returned with the resource array. * * @param \Illuminate\Http\Request $request * @return array */ public function with($request) { return [ 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), 'workflow' => $this->workflows(), 'actions' => $this->actions(), ], ]; } private function workflows() { $arr = []; $workflow = $this->workflow(); foreach ($workflow->transitions($this) as $key => $transition) { $name = $transition->getName(); $arr[$key]['url'] = guard_url('example/example/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('example::example.workflow.' . $name); } return $arr; } private function actions() { $arr = []; return $arr; } }