Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction in Job.php class #36

Open
CarCarlo1977 opened this issue Jun 13, 2024 · 1 comment
Open

Correction in Job.php class #36

CarCarlo1977 opened this issue Jun 13, 2024 · 1 comment

Comments

@CarCarlo1977
Copy link

Your code in laravel 10.x return the error: Smalot\Cups\Model\Job::addBinary(): Argument #1 ($stream) must be of type Smalot\Cups\Model\resource, resource given, called in /var/www/labradiant/vendor/julianosorio078/cups-ipp/src/Model/Job.php on line 278

This is my corrected code that works:

copies = 1; $this->sides = self::SIDES_ONE_SIDED; } public function getId() { return $this->id; } public function setId($id) { $this->id = $id; return $this; } public function getPrinterUri() { return $this->printerUri; } public function setPrinterUri($printerUri) { $this->printerUri = $printerUri; return $this; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; return $this; } public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; return $this; } public function getPageRanges() { return $this->pageRanges; } public function setPageRanges($pageRanges) { $this->pageRanges = $pageRanges; return $this; } public function getCopies() { return $this->copies; } public function setCopies($copies) { $this->copies = $copies; return $this; } public function getSides() { return ($this->sides ?: self::SIDES_ONE_SIDED); } public function setSides($sides) { $this->sides = $sides; return $this; } public function getFidelity() { return $this->fidelity; } public function setFidelity($fidelity) { $this->fidelity = $fidelity; return $this; } public function getContent() { return $this->content; } public function addFile($filename, $name = '', $mimeType = null) { if (empty($name)) { $name = basename($filename); } if ($mimeType === null) { $mimeType = mimetype_from_filename($filename); } return $this->addBinary(fopen($filename, 'r'), $name, $mimeType); } /** * @param resource $stream * @param string $name * @param string $mimeType * * @return Job */ public function addBinary($stream, $name, $mimeType = null) { if ($mimeType === null && class_exists(finfo::class)) { $finfo = new finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->buffer(stream_get_contents($stream)); rewind($stream); // Reset the stream pointer to the beginning } $mimeType = is_string($mimeType) ? $mimeType : 'application/octet-stream'; $this->content[] = [ 'type' => self::CONTENT_FILE, 'name' => $name, 'mimeType' => $mimeType, 'binary' => stream_get_contents($stream), ]; return $this; } public function addText($text, $name = '', $mimeType = 'text/plain') { $this->content[] = [ 'type' => self::CONTENT_TEXT, 'name' => $name, 'mimeType' => $mimeType, 'text' => $text, ]; return $this; } public function getState() { return $this->state; } public function setState($state) { $this->state = $state; return $this; } public function getStateReason() { return $this->stateReason; } public function setStateReason($stateReason) { $this->stateReason = $stateReason; return $this; } }
@CarCarlo1977
Copy link
Author

Job.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant