-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/releasing-localization-demo-v2'
- Loading branch information
Showing
16 changed files
with
423 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace WebReinvent\VaahCms\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class VaahExcelFacade extends Facade { | ||
|
||
protected static function getFacadeAccessor() { | ||
return 'vaahexcel'; | ||
} | ||
|
||
} |
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,12 @@ | ||
<?php | ||
namespace WebReinvent\VaahCms\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class VaahFileFacade extends Facade { | ||
|
||
protected static function getFacadeAccessor() { | ||
return 'vaahfile'; | ||
} | ||
|
||
} |
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,10 @@ | ||
<?php | ||
namespace WebReinvent\VaahCms\Libraries; | ||
|
||
class VaahExcel{ | ||
|
||
public function helloWorld() { | ||
echo "Testing the Facades in Laravel."; | ||
} | ||
|
||
} |
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,123 @@ | ||
<?php | ||
namespace WebReinvent\VaahCms\Libraries; | ||
|
||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class VaahFile{ | ||
|
||
//------------------------------------------------------------ | ||
public function upload($request) { | ||
|
||
|
||
|
||
if(!$request->hasFile('file')){ | ||
$response['status'] = 'failed'; | ||
$response['errors'][] = 'No file to upload.'; | ||
return $response; | ||
} | ||
|
||
$file_params = $this->getUploadFileParams($request); | ||
|
||
echo "<pre>"; | ||
print_r($file_params); | ||
echo "</pre>"; | ||
die("<hr/>line number=123"); | ||
|
||
$request->merge($file_params); | ||
|
||
$rules = array( | ||
'file' => 'required', | ||
'path' => 'required', | ||
'allowed_extensions' => 'required|array', | ||
); | ||
|
||
$validator = \Validator::make( $request->all(), $rules); | ||
if ( $validator->fails() ) { | ||
|
||
$errors = errorsToArray($validator->errors()); | ||
$response['status'] = 'failed'; | ||
$response['errors'] = $errors; | ||
return $response; | ||
} | ||
|
||
if(!in_array($request->file_extension, $request->allowed_extensions)) | ||
{ | ||
$response['status'] = 'failed'; | ||
$response['errors'][] = 'File extension '.$request->file_extension.' is not allowed to upload'; | ||
return $response; | ||
} | ||
|
||
|
||
try{ | ||
|
||
Storage::disk('local')->putFileAs( | ||
$request->upload_folder_path, | ||
$request->file('file'), | ||
$request->upload_file_name | ||
); | ||
|
||
}catch(\Exception $e) | ||
{ | ||
$response['status'] = 'failed'; | ||
$response['messages'][] = $e->getMessage(); | ||
return $response; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
//------------------------------------------------------------ | ||
public function getUploadFileParams($request) | ||
{ | ||
|
||
$params = $request->all(); | ||
if(!$request->has('upload_folder_path')) | ||
{ | ||
$date = date('y-m-d'); | ||
$folder = storage_path('uploads/'.$date); | ||
$params['upload_folder_path'] = $folder; | ||
} | ||
|
||
if(!$request->has('file_name')) | ||
{ | ||
$params['file_name'] = $request->file('file')->getClientOriginalName(); | ||
} | ||
|
||
$params['file_extension'] = $request->file('file')->getClientOriginalExtension(); | ||
|
||
$params['upload_file_name'] = $params['file_name'].".".$params['file_extension']; | ||
|
||
$params['upload_file_path'] = $params['upload_folder_path']."/".$params['upload_file_name']; | ||
|
||
if(File::exist($params['upload_file_path'])) | ||
{ | ||
$file_name = $params['file_name']."-".date('Y-m-d-H-i-s'); | ||
$file_name = $file_name.".".$params['file_extension']; | ||
$params['upload_file_name'] = $file_name; | ||
$params['upload_file_path'] = $params['upload_folder_path']."/".$file_name; | ||
} | ||
|
||
|
||
if(!$request->has('allowed_extensions')) | ||
{ | ||
$uploads = config('vaahcms.uploads'); | ||
$allowed_extensions = $uploads['allowed_extensions']; | ||
$params['allowed_extensions'] = $allowed_extensions; | ||
} | ||
|
||
return $params; | ||
|
||
} | ||
//------------------------------------------------------------ | ||
|
||
//------------------------------------------------------------ | ||
//------------------------------------------------------------ | ||
//------------------------------------------------------------ | ||
//------------------------------------------------------------ | ||
//------------------------------------------------------------ | ||
|
||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace WebReinvent\VaahCms\Providers; | ||
|
||
use App; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use WebReinvent\VaahCms\Libraries\VaahExcel; | ||
use WebReinvent\VaahCms\Libraries\VaahFile; | ||
|
||
|
||
|
||
class FacadesServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Booting the package. | ||
*/ | ||
public function boot() | ||
{ | ||
} | ||
|
||
/** | ||
* Register the provider. | ||
*/ | ||
public function register() | ||
{ | ||
|
||
App::bind('vaahexcel',function() { | ||
return new VaahExcel(); | ||
}); | ||
|
||
App::bind('vaahfile',function() { | ||
return new VaahFile(); | ||
}); | ||
|
||
} | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.