♻️ Replace App\Model with App\Data
This commit is contained in:
parent
70e4404c22
commit
7f4f005302
12 changed files with 393 additions and 222 deletions
19
app/Data/Casts/File.php
Normal file
19
app/Data/Casts/File.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Data\Casts;
|
||||
|
||||
use App\Exceptions\Quit;
|
||||
use Spatie\LaravelData\Casts\Cast;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class File implements Cast
|
||||
{
|
||||
public function cast(DataProperty $property, mixed $file, array $context): mixed
|
||||
{
|
||||
if (!file_exists($file)) {
|
||||
throw new Quit("$file is not a valid file");
|
||||
}
|
||||
|
||||
return realpath($file);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue