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