-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from mostafaznv/dev
Dev
- Loading branch information
Showing
8 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Mostafaznv\Larupload\LaruploadEnum; | ||
use Mostafaznv\Larupload\Storage\Attachment; | ||
use Mostafaznv\Larupload\Traits\Larupload; | ||
use Exception; | ||
|
||
class Video extends Model | ||
{ | ||
use Larupload; | ||
|
||
protected $fillable = ['name', 'file', 'disk']; | ||
|
||
protected static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::saving(function($model) { | ||
$hasLaruploadTrait = method_exists(self::class, 'bootLarupload'); | ||
|
||
if (!$model->name) { | ||
$name = $hasLaruploadTrait ? $model->file->meta('name') : $model->file; | ||
|
||
$model->name = pathinfo($name, PATHINFO_FILENAME); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function attachments(): array | ||
{ | ||
return [ | ||
Attachment::make('file') | ||
->disk('video') | ||
->namingMethod(LaruploadEnum::HASH_FILE_NAMING_METHOD) | ||
->coverStyle(852, 480, LaruploadEnum::AUTO_STYLE_MODE), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters