action = $action; $this->request = $request; $this->model = $feed; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Feed $feed, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $feed = $feed->create($attributes); return $feed; } public function update(Feed $feed, array $request) { $attributes = $request; $feed->update($attributes); return $feed; } public function destroy(Feed $feed, array $request) { $feed->delete(); return $feed; } public function copy(Feed $feed, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $feed = $feed->replicate(); $feed->created_at = Carbon::now(); $feed->save(); return $feed; } for ($i = 1; $i <= $count; $i++) { $new = $feed->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $feed; } }