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