@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('exports', function (Blueprint $table) { |
|
16 | + Schema::create('exports', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->string('file', 255)->nullable(); |
19 | 19 | $table->string('type', 10); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('imports', function (Blueprint $table) { |
|
16 | + Schema::create('imports', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->string('file', 255); |
19 | 19 | $table->integer('file_rows'); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('import_export_logs', function (Blueprint $table) { |
|
16 | + Schema::create('import_export_logs', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->integer('op_id'); |
19 | 19 | $table->longText('data'); |
@@ -10,23 +10,23 @@ discard block |
||
10 | 10 | |
11 | 11 | |
12 | 12 | /** |
13 | - * Relationship with import model |
|
14 | - * |
|
15 | - * @return void |
|
16 | - */ |
|
13 | + * Relationship with import model |
|
14 | + * |
|
15 | + * @return void |
|
16 | + */ |
|
17 | 17 | public function import() |
18 | 18 | { |
19 | - return $this->belongsTo( \Ladybirdweb\ImportExport\Models\Import::class ); |
|
19 | + return $this->belongsTo( \Ladybirdweb\ImportExport\Models\Import::class ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | /** |
24 | - * Model Map accessor |
|
25 | - * |
|
26 | - * Unserialize data while retriving. |
|
27 | - * @param $value |
|
28 | - * @return string |
|
29 | - */ |
|
24 | + * Model Map accessor |
|
25 | + * |
|
26 | + * Unserialize data while retriving. |
|
27 | + * @param $value |
|
28 | + * @return string |
|
29 | + */ |
|
30 | 30 | public function getDataAttribute($value) |
31 | 31 | { |
32 | 32 | return unserialize( $value ); |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
37 | - * Model Map mulator |
|
38 | - * |
|
39 | - * Serialize data while storing. |
|
40 | - * @param $value |
|
41 | - * @return void |
|
42 | - */ |
|
37 | + * Model Map mulator |
|
38 | + * |
|
39 | + * Serialize data while storing. |
|
40 | + * @param $value |
|
41 | + * @return void |
|
42 | + */ |
|
43 | 43 | public function setDataAttribute($value) |
44 | 44 | { |
45 | 45 | $this->attributes['data'] = serialize( $value ); |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * Model Map accessor |
|
51 | - * |
|
52 | - * Unserialize message while retriving. |
|
53 | - * @param $value |
|
54 | - * @return string |
|
55 | - */ |
|
50 | + * Model Map accessor |
|
51 | + * |
|
52 | + * Unserialize message while retriving. |
|
53 | + * @param $value |
|
54 | + * @return string |
|
55 | + */ |
|
56 | 56 | public function getMessageAttribute($value) |
57 | 57 | { |
58 | 58 | return unserialize( $value ); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
63 | - * Model Map mulator |
|
64 | - * |
|
65 | - * Serialize message while storing. |
|
66 | - * @param $value |
|
67 | - * @return void |
|
68 | - */ |
|
63 | + * Model Map mulator |
|
64 | + * |
|
65 | + * Serialize message while storing. |
|
66 | + * @param $value |
|
67 | + * @return void |
|
68 | + */ |
|
69 | 69 | public function setMessageAttribute($value) |
70 | 70 | { |
71 | 71 | $this->attributes['message'] = serialize( $value ); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function import() |
18 | 18 | { |
19 | - return $this->belongsTo( \Ladybirdweb\ImportExport\Models\Import::class ); |
|
19 | + return $this->belongsTo(\Ladybirdweb\ImportExport\Models\Import::class); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getDataAttribute($value) |
31 | 31 | { |
32 | - return unserialize( $value ); |
|
32 | + return unserialize($value); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function setDataAttribute($value) |
44 | 44 | { |
45 | - $this->attributes['data'] = serialize( $value ); |
|
45 | + $this->attributes['data'] = serialize($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getMessageAttribute($value) |
57 | 57 | { |
58 | - return unserialize( $value ); |
|
58 | + return unserialize($value); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,6 +68,6 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setMessageAttribute($value) |
70 | 70 | { |
71 | - $this->attributes['message'] = serialize( $value ); |
|
71 | + $this->attributes['message'] = serialize($value); |
|
72 | 72 | } |
73 | 73 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | protected $fillable = [ 'file', 'type', 'query', 'result_rows']; |
10 | 10 | |
11 | 11 | /** |
12 | - * Query accessor |
|
13 | - * |
|
14 | - * Unserialize query while retriving. |
|
15 | - * @param $value |
|
16 | - * @return string |
|
17 | - */ |
|
12 | + * Query accessor |
|
13 | + * |
|
14 | + * Unserialize query while retriving. |
|
15 | + * @param $value |
|
16 | + * @return string |
|
17 | + */ |
|
18 | 18 | public function getQueryAttribute($value) |
19 | 19 | { |
20 | 20 | return unserialize( $value ); |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | /** |
25 | - * Query mulator |
|
26 | - * |
|
27 | - * Serialize query while storing. |
|
28 | - * @param $value |
|
29 | - * @return void |
|
30 | - */ |
|
25 | + * Query mulator |
|
26 | + * |
|
27 | + * Serialize query while storing. |
|
28 | + * @param $value |
|
29 | + * @return void |
|
30 | + */ |
|
31 | 31 | public function setQueryAttribute($value) |
32 | 32 | { |
33 | 33 | $this->attributes['query'] = serialize( $value ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | class Export extends Model |
8 | 8 | { |
9 | - protected $fillable = [ 'file', 'type', 'query', 'result_rows']; |
|
9 | + protected $fillable = ['file', 'type', 'query', 'result_rows']; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Query accessor |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function getQueryAttribute($value) |
19 | 19 | { |
20 | - return unserialize( $value ); |
|
20 | + return unserialize($value); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -30,6 +30,6 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function setQueryAttribute($value) |
32 | 32 | { |
33 | - $this->attributes['query'] = serialize( $value ); |
|
33 | + $this->attributes['query'] = serialize($value); |
|
34 | 34 | } |
35 | 35 | } |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | |
7 | 7 | class Import extends Model |
8 | 8 | { |
9 | - protected $fillable = ['file', 'file_rows', 'db_cols', 'row_processed']; |
|
9 | + protected $fillable = ['file', 'file_rows', 'db_cols', 'row_processed']; |
|
10 | 10 | |
11 | 11 | |
12 | 12 | /** |
13 | - * Relationship with import export log model |
|
14 | - * |
|
15 | - * @return void |
|
16 | - */ |
|
13 | + * Relationship with import export log model |
|
14 | + * |
|
15 | + * @return void |
|
16 | + */ |
|
17 | 17 | public function importLogs() |
18 | 18 | { |
19 | - return $this->hasMany( \Ladybirdweb\ImportExport\Models\ImportExportLog::class, 'op_id' ); |
|
19 | + return $this->hasMany( \Ladybirdweb\ImportExport\Models\ImportExportLog::class, 'op_id' ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | /** |
24 | - * Model Map accessor |
|
25 | - * |
|
26 | - * Unserialize model map while retriving. |
|
27 | - * @param $value |
|
28 | - * @return string |
|
29 | - */ |
|
24 | + * Model Map accessor |
|
25 | + * |
|
26 | + * Unserialize model map while retriving. |
|
27 | + * @param $value |
|
28 | + * @return string |
|
29 | + */ |
|
30 | 30 | public function getModelMapAttribute($value) |
31 | 31 | { |
32 | 32 | return unserialize( $value ); |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
37 | - * Model Map mulator |
|
38 | - * |
|
39 | - * Serialize model map while storing. |
|
40 | - * @param $value |
|
41 | - * @return void |
|
42 | - */ |
|
37 | + * Model Map mulator |
|
38 | + * |
|
39 | + * Serialize model map while storing. |
|
40 | + * @param $value |
|
41 | + * @return void |
|
42 | + */ |
|
43 | 43 | public function setModelMapAttribute($value) |
44 | 44 | { |
45 | 45 | $this->attributes['model_map'] = serialize( $value ); |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * DB cols accessor |
|
51 | - * |
|
52 | - * Unserialize model map while retriving. |
|
53 | - * @param $value |
|
54 | - * @return string |
|
55 | - */ |
|
50 | + * DB cols accessor |
|
51 | + * |
|
52 | + * Unserialize model map while retriving. |
|
53 | + * @param $value |
|
54 | + * @return string |
|
55 | + */ |
|
56 | 56 | public function getDbColsAttribute($value) |
57 | 57 | { |
58 | 58 | return unserialize( $value ); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
63 | - * Model Map mulator |
|
64 | - * |
|
65 | - * Serialize model map while storing. |
|
66 | - * @param $value |
|
67 | - * @return void |
|
68 | - */ |
|
63 | + * Model Map mulator |
|
64 | + * |
|
65 | + * Serialize model map while storing. |
|
66 | + * @param $value |
|
67 | + * @return void |
|
68 | + */ |
|
69 | 69 | public function setDbColsAttribute($value) |
70 | 70 | { |
71 | 71 | $this->attributes['db_cols'] = serialize( $value ); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function importLogs() |
18 | 18 | { |
19 | - return $this->hasMany( \Ladybirdweb\ImportExport\Models\ImportExportLog::class, 'op_id' ); |
|
19 | + return $this->hasMany(\Ladybirdweb\ImportExport\Models\ImportExportLog::class, 'op_id'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function getModelMapAttribute($value) |
31 | 31 | { |
32 | - return unserialize( $value ); |
|
32 | + return unserialize($value); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function setModelMapAttribute($value) |
44 | 44 | { |
45 | - $this->attributes['model_map'] = serialize( $value ); |
|
45 | + $this->attributes['model_map'] = serialize($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getDbColsAttribute($value) |
57 | 57 | { |
58 | - return unserialize( $value ); |
|
58 | + return unserialize($value); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,6 +68,6 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setDbColsAttribute($value) |
70 | 70 | { |
71 | - $this->attributes['db_cols'] = serialize( $value ); |
|
71 | + $this->attributes['db_cols'] = serialize($value); |
|
72 | 72 | } |
73 | 73 | } |
@@ -14,27 +14,27 @@ discard block |
||
14 | 14 | public function boot() |
15 | 15 | { |
16 | 16 | // Register routes |
17 | - $this->loadRoutesFrom( __DIR__ . '/routes.php' ); |
|
17 | + $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
18 | 18 | |
19 | 19 | // Register database migrations |
20 | - $this->loadMigrationsFrom( __DIR__ . '/../database/migrations' ); |
|
20 | + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
21 | 21 | |
22 | 22 | // Load views |
23 | - $this->loadViewsFrom( __DIR__ . '/../resources/views', 'importexport' ); |
|
23 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'importexport'); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'ladybirdweb'); |
27 | 27 | |
28 | 28 | // Publishing is only necessary when using the CLI. |
29 | - if ( $this->app->runningInConsole() ) { |
|
29 | + if ($this->app->runningInConsole()) { |
|
30 | 30 | |
31 | 31 | // Publishing the configuration file. |
32 | 32 | $this->publishes([ |
33 | - __DIR__ . '/../config/import.php' => config_path('ladybirdweb/import-export/import.php'), |
|
33 | + __DIR__.'/../config/import.php' => config_path('ladybirdweb/import-export/import.php'), |
|
34 | 34 | ], 'import-export.config'); |
35 | 35 | |
36 | 36 | $this->publishes([ |
37 | - __DIR__ . '/../config/export.php' => config_path('ladybirdweb/import-export/export.php'), |
|
37 | + __DIR__.'/../config/export.php' => config_path('ladybirdweb/import-export/export.php'), |
|
38 | 38 | ], 'import-export.config'); |
39 | 39 | |
40 | 40 | // Publishing the views. |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | public function register() |
59 | 59 | { |
60 | 60 | // Merge config |
61 | - $this->mergeConfigFrom( __DIR__ . '/../config/import.php', 'import' ); |
|
62 | - $this->mergeConfigFrom( __DIR__ . '/../config/export.php', 'export' ); |
|
61 | + $this->mergeConfigFrom(__DIR__.'/../config/import.php', 'import'); |
|
62 | + $this->mergeConfigFrom(__DIR__.'/../config/export.php', 'export'); |
|
63 | 63 | |
64 | 64 | // Register fecades |
65 | - $this->app->singleton( 'import', 'Ladybirdweb\ImportExport\Import' ); |
|
66 | - $this->app->singleton( 'importhandler', 'Ladybirdweb\ImportExport\ImportHandler' ); |
|
67 | - $this->app->singleton( 'importexportlog', 'Ladybirdweb\ImportExport\ImportExportLog' ); |
|
65 | + $this->app->singleton('import', 'Ladybirdweb\ImportExport\Import'); |
|
66 | + $this->app->singleton('importhandler', 'Ladybirdweb\ImportExport\ImportHandler'); |
|
67 | + $this->app->singleton('importexportlog', 'Ladybirdweb\ImportExport\ImportExportLog'); |
|
68 | 68 | |
69 | - $this->app->singleton( 'export', 'Ladybirdweb\ImportExport\Export' ); |
|
69 | + $this->app->singleton('export', 'Ladybirdweb\ImportExport\Export'); |
|
70 | 70 | |
71 | 71 | // Register import controller |
72 | - $this->app->singleton( 'Ladybirdweb\ImportExport\Import' ); |
|
72 | + $this->app->singleton('Ladybirdweb\ImportExport\Import'); |
|
73 | 73 | |
74 | 74 | // Register import handler |
75 | - $this->app->singleton( 'Ladybirdweb\ImportExport\ImportHandler' ); |
|
75 | + $this->app->singleton('Ladybirdweb\ImportExport\ImportHandler'); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 |
@@ -7,20 +7,20 @@ |
||
7 | 7 | class ImportExportLog |
8 | 8 | { |
9 | 9 | |
10 | - public function logImportError(Import $import, $data, $message) |
|
11 | - { |
|
12 | - // Create new log |
|
13 | - return $import->importLogs()->create([ |
|
14 | - 'data' => $data, |
|
15 | - 'message' => $message, |
|
16 | - ]); |
|
17 | - } |
|
10 | + public function logImportError(Import $import, $data, $message) |
|
11 | + { |
|
12 | + // Create new log |
|
13 | + return $import->importLogs()->create([ |
|
14 | + 'data' => $data, |
|
15 | + 'message' => $message, |
|
16 | + ]); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - public function getLogs($id) |
|
21 | - { |
|
22 | - // Get all logs of a import or export process |
|
23 | - return Import::findOrFail( $id )->importLogs()->get( [ 'data', 'message' ] )->toArray(); |
|
24 | - } |
|
20 | + public function getLogs($id) |
|
21 | + { |
|
22 | + // Get all logs of a import or export process |
|
23 | + return Import::findOrFail( $id )->importLogs()->get( [ 'data', 'message' ] )->toArray(); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function getLogs($id) |
21 | 21 | { |
22 | 22 | // Get all logs of a import or export process |
23 | - return Import::findOrFail( $id )->importLogs()->get( [ 'data', 'message' ] )->toArray(); |
|
23 | + return Import::findOrFail($id)->importLogs()->get(['data', 'message'])->toArray(); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
@@ -9,24 +9,24 @@ discard block |
||
9 | 9 | class Export |
10 | 10 | { |
11 | 11 | |
12 | - public function export(Builder $query, $ext = 'xls') |
|
13 | - { |
|
14 | - // Create new export |
|
15 | - $export = new ModelExport; |
|
12 | + public function export(Builder $query, $ext = 'xls') |
|
13 | + { |
|
14 | + // Create new export |
|
15 | + $export = new ModelExport; |
|
16 | 16 | |
17 | - $export->type = $ext; |
|
18 | - $export->query = $query->getModel(); |
|
17 | + $export->type = $ext; |
|
18 | + $export->query = $query->getModel(); |
|
19 | 19 | |
20 | - $export->save(); |
|
20 | + $export->save(); |
|
21 | 21 | |
22 | - ExportJob::dispatch( $export )->onQueue( 'exporting' ); |
|
22 | + ExportJob::dispatch( $export )->onQueue( 'exporting' ); |
|
23 | 23 | |
24 | - return $export; |
|
25 | - } |
|
24 | + return $export; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - public function showExportStatus($id) |
|
29 | + public function showExportStatus($id) |
|
30 | 30 | { |
31 | 31 | // Map export instance |
32 | 32 | $export = ModelExport::findOrFail( $id ); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | if ( $export->result_rows > 0 ) { |
52 | 52 | |
53 | - $data['progress'] = round( ( $export->row_processed / $export->result_rows ) * 100 ); |
|
53 | + $data['progress'] = round( ( $export->row_processed / $export->result_rows ) * 100 ); |
|
54 | 54 | |
55 | 55 | } else { |
56 | 56 | |
57 | - $data['progress'] = 0; |
|
57 | + $data['progress'] = 0; |
|
58 | 58 | |
59 | 59 | } |
60 | 60 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | $export->save(); |
21 | 21 | |
22 | - ExportJob::dispatch( $export )->onQueue( 'exporting' ); |
|
22 | + ExportJob::dispatch($export)->onQueue('exporting'); |
|
23 | 23 | |
24 | 24 | return $export; |
25 | 25 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | public function showExportStatus($id) |
30 | 30 | { |
31 | 31 | // Map export instance |
32 | - $export = ModelExport::findOrFail( $id ); |
|
32 | + $export = ModelExport::findOrFail($id); |
|
33 | 33 | |
34 | - return view( 'importexport::export.progress', compact( 'id' ) ); |
|
34 | + return view('importexport::export.progress', compact('id')); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | public function returnExportProgress($id) |
45 | 45 | { |
46 | 46 | // Map export instance |
47 | - $export = ModelExport::findOrFail( $id ); |
|
47 | + $export = ModelExport::findOrFail($id); |
|
48 | 48 | |
49 | 49 | $data['status'] = 200; |
50 | 50 | |
51 | - if ( $export->result_rows > 0 ) { |
|
51 | + if ($export->result_rows > 0) { |
|
52 | 52 | |
53 | - $data['progress'] = round( ( $export->row_processed / $export->result_rows ) * 100 ); |
|
53 | + $data['progress'] = round(($export->row_processed / $export->result_rows) * 100); |
|
54 | 54 | |
55 | 55 | } else { |
56 | 56 | |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | // If progress completed return successful imported rows count |
62 | - if ( $data['progress'] == 100 ) { |
|
63 | - $data['exported'] = route( 'ladybirdweb.export.download', $export->id ); |
|
62 | + if ($data['progress'] == 100) { |
|
63 | + $data['exported'] = route('ladybirdweb.export.download', $export->id); |
|
64 | 64 | } |
65 | 65 | |
66 | - return response()->json( $data ); |
|
66 | + return response()->json($data); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | 70 | public function downloadExportedFile($id) |
71 | 71 | { |
72 | 72 | // Map export instance |
73 | - $export = ModelExport::findOrFail( $id ); |
|
73 | + $export = ModelExport::findOrFail($id); |
|
74 | 74 | |
75 | - if ( ! file_exists( storage_path( 'app/exports' ) . '/' . $export->file ) || empty( $export->file ) ) { |
|
75 | + if (!file_exists(storage_path('app/exports').'/'.$export->file) || empty($export->file)) { |
|
76 | 76 | abort(404); |
77 | 77 | } |
78 | 78 | |
79 | - return response()->download( storage_path( 'app/exports/' . $export->file ) ); |
|
79 | + return response()->download(storage_path('app/exports/'.$export->file)); |
|
80 | 80 | } |
81 | 81 | } |