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