-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #205 Fixed: Deleting/saving attached files gives Whoops
- Loading branch information
1 parent
968219a
commit 0036553
Showing
10 changed files
with
55 additions
and
18 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
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
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
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,37 @@ | ||
<?php | ||
|
||
namespace App\Traits; | ||
|
||
use Plank\Mediable\Mediable; | ||
|
||
/** | ||
* Mediable Trait. | ||
* | ||
* Provides functionality for attaching media to an eloquent model. | ||
* | ||
* @author Sean Fraser <sean@plankdesign.com> | ||
* | ||
* Whether the model should automatically reload its media relationship after modification. | ||
*/ | ||
trait Media | ||
{ | ||
use Mediable; | ||
|
||
/** | ||
* Relationship for all attached media. | ||
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany | ||
*/ | ||
public function media() | ||
{ | ||
$media = $this->morphToMany(config('mediable.model'), 'mediable') | ||
->withPivot('tag', 'order') | ||
->orderBy('order'); | ||
|
||
// Skip deleted media if not detached | ||
if (config('mediable.detach_on_soft_delete') == false) { | ||
$media->whereNull('deleted_at'); | ||
} | ||
|
||
return $media; | ||
} | ||
} |