Skip to content

Commit 398e6d9

Browse files
committed
wip
1 parent 43c9b3f commit 398e6d9

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

phpunit.xml.dist

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3-
<coverage>
4-
<report>
5-
<clover outputFile="build/logs/clover.xml"/>
6-
</report>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
87
<testsuites>
98
<testsuite name="Root">
109
<directory suffix="Test.php">./tests</directory>
@@ -14,7 +13,7 @@
1413
<server name="APP_KEY" value="base64:ybq4vTLI2AtF1xqSRZ8A52CtU9dUXu1yAcClXsNKGq4="/>
1514
<server name="APP_ENV" value="testing"/>
1615
<server name="BCRYPT_ROUNDS" value="4"/>
17-
<server name="CACHE_DRIVER" value="array"/>
16+
<server name="CACHE_STORE" value="array"/>
1817
<server name="DB_CONNECTION" value="sqlite"/>
1918
<server name="DB_DATABASE" value=":memory:"/>
2019
<server name="MAIL_MAILER" value="array"/>

src/Models/Medium.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Cone\Root\Support\Facades\Conversion;
1414
use Cone\Root\Traits\Filterable;
1515
use Cone\Root\Traits\InteractsWithProxy;
16+
use Illuminate\Contracts\Mail\Attachable;
1617
use Illuminate\Database\Eloquent\Attributes\Scope;
1718
use Illuminate\Database\Eloquent\Builder;
1819
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
@@ -22,6 +23,7 @@
2223
use Illuminate\Database\Eloquent\Model;
2324
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2425
use Illuminate\Http\UploadedFile;
26+
use Illuminate\Mail\Attachment;
2527
use Illuminate\Support\Facades\App;
2628
use Illuminate\Support\Facades\Config;
2729
use Illuminate\Support\Facades\Response;
@@ -31,7 +33,7 @@
3133
use Illuminate\Support\Str;
3234
use Symfony\Component\HttpFoundation\BinaryFileResponse;
3335

34-
class Medium extends Model implements Contract
36+
class Medium extends Model implements Attachable, Contract
3537
{
3638
use Filterable;
3739
use HasFactory;
@@ -340,4 +342,14 @@ protected function type(Builder $query, string $value): Builder
340342
default => $query,
341343
};
342344
}
345+
346+
/**
347+
* Get an attachment instance for this entity.
348+
*/
349+
public function toMailAttachment(): Attachment
350+
{
351+
return Attachment::fromPath($this->getAbsolutePath())
352+
->as($this->file_name)
353+
->mime($this->mime_type);
354+
}
343355
}

0 commit comments

Comments
 (0)