-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UploadsFiles triat for Model coupled upload #23
- Loading branch information
Jovert Lota Palonpon
committed
Mar 30, 2019
1 parent
def767a
commit dee767e
Showing
9 changed files
with
80 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Contracts; | ||
|
||
interface Uploader | ||
{ | ||
/** | ||
* Get the directory. | ||
* | ||
* @return string | ||
*/ | ||
public function getDirectory() : string; | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace App\Traits; | ||
|
||
use Uploader; | ||
use Illuminate\Http\UploadedFile; | ||
|
||
trait UploadsFiles | ||
{ | ||
/** | ||
* Handle the upload for the uploader, and update it's attributes. | ||
* | ||
* @param Illuminate\Http\UploadedFile | ||
* | ||
* @return bool | ||
*/ | ||
public function upload(UploadedFile $file) | ||
{ | ||
$upload = Uploader::upload($this->getDirectory(), $file); | ||
|
||
foreach ($upload as $attribute => $value) { | ||
$this->attributes[$attribute] = $value; | ||
} | ||
|
||
return $this->update(); | ||
} | ||
} |
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 was deleted.
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