-
Notifications
You must be signed in to change notification settings - Fork 2
126 feature excel processor #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gunesbizim
wants to merge
13
commits into
dev
Choose a base branch
from
126-feature-excel-processor
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6393e9b
fix: :bug: fix change method that gets path on artisan call in paymen…
gunesbizim a0214a7
fix: :bug: fix SpreadableTrait && HasSpreadable && refactor Spreadabl…
gunesbizim f7d18eb
fix: :bug: fix spreadable and spreadsheet && refactor spreadable
gunesbizim 1fe8306
feat: :sparkles: introduce reporting module && spreadsheet features
gunesbizim 2cc5a29
Merge branch '7-feature-add-reporter-module' into 126-feature-excel-p…
gunesbizim f6daf82
feat: :sparkles: introduce spreadsheet feature && fix small bug at in…
gunesbizim 4b3de7a
fix: :bug: fix variable name typo && update migrationg with role, loc…
gunesbizim c392047
refactor: :recycle: remove unnecessary line of code
gunesbizim 7490975
refactor: :recycle: clean unnecessary comment lines
gunesbizim 52de313
refactor: :recycle: clean unnecessary comment lines
gunesbizim b0b8380
refactor: :recycle: wrap spreadsheet input with v-input
gunesbizim c2f3c45
fix: :bug: fix processTableData function on spreadsheet input && add …
gunesbizim 8847623
feat: :sparkles: introduce translateable spreadsheets
gunesbizim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
44 changes: 44 additions & 0 deletions
44
database/migrations/default/2025_01_30_103120_create_spreadsheets_table.php
This file contains hidden or 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 | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
| use Illuminate\Database\Query\Expression; | ||
| use Illuminate\Support\Str; | ||
|
|
||
|
|
||
|
|
||
| class CreateSpreadsheetsTable extends Migration | ||
| { | ||
| public function up() | ||
| { | ||
| $modularitySpreadsheetsTable = modularityConfig('tables.spreadsheets', 'modularity_spreadsheets'); | ||
|
|
||
| Schema::create($modularitySpreadsheetsTable, function (Blueprint $table) { | ||
| // this will create an id, name field | ||
| createDefaultTableFields($table); | ||
| $table->uuidMorphs('spreadsheetable'); | ||
| $table->json('content')->default(new Expression('(JSON_ARRAY())')); | ||
| $table->string('role')->nullable(); | ||
| $table->string('locale')->nullable(); | ||
| // a "published" column, and soft delete and timestamps columns | ||
| createDefaultExtraTableFields($table); | ||
| }); | ||
|
|
||
| Schema::create('spreadsheet_translations', function (Blueprint $table) { | ||
| // createDefaultTranslationsTableFields($table, Str::singular(modularityConfig('tables.spreadsheets', 'modularity_spreadsheets'))); | ||
| createDefaultTranslationsTableFields($table, 'spreadsheet'); | ||
|
|
||
| $table->json('content')->default(new Expression('(JSON_ARRAY())'));; | ||
| }); | ||
|
|
||
|
|
||
| } | ||
|
|
||
| public function down() | ||
| { | ||
| Schema::dropIfExists('spreadsheet_translations'); | ||
| Schema::dropIfExists(modularityConfig('tables.spreadsheets', 'modularity_spreadsheets')); | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
| <?php | ||
|
|
||
| namespace Unusualify\Modularity\Entities; | ||
|
|
||
| use Unusualify\Modularity\Entities\Model; | ||
| use Modules\PressRelease\Entities\Report; | ||
| use Unusualify\Modularity\Entities\Traits\HasTranslation; | ||
|
|
||
| class Spreadsheet extends Model | ||
| { | ||
| /** | ||
| * The attributes that are mass assignable. | ||
| * | ||
| * @var array<int, string> | ||
| */ | ||
| use HasTranslation; | ||
|
|
||
| public $translatedAttributes = [ | ||
| 'content' | ||
| ]; | ||
|
|
||
| protected $fillable = [ | ||
| 'published', | ||
| // 'content', | ||
| 'role', | ||
| 'locale' | ||
| ]; | ||
|
|
||
| protected $casts = [ | ||
| 'content' => 'array' | ||
| ]; | ||
|
|
||
| public function __construct(array $attributes = []) | ||
| { | ||
| $this->table = $this->getTable(); | ||
| parent::__construct($attributes); | ||
| } | ||
|
|
||
| public function getTable() | ||
| { | ||
| return modularityConfig('tables.spreadsheets', 'modularity_spreads'); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,96 @@ | ||
| <?php | ||
|
|
||
| namespace Unusualify\Modularity\Entities\Traits; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
|
|
||
| trait HasSpreadsheetable | ||
| { | ||
|
|
||
|
|
||
| protected $_pendingSpreadsheetData = []; | ||
|
|
||
| /** | ||
| * Perform any actions when booting the trait | ||
| * | ||
| * @return void | ||
| */ | ||
| public static function bootHasSpreadsheetable(): void | ||
| { | ||
| static::retrieved(function (Model $model) { | ||
| // Assuming you have one spreadsheet per locale | ||
| $spreadsheet = $model->spreadsheetable()->first(); | ||
| if ($spreadsheet) { | ||
| // Load the spreadsheet's translation for the current locale | ||
| $translatedSpreadsheet = $spreadsheet->translateOrDefault(app()->getLocale()); | ||
| $model->setAttribute('_spreadsheet', $translatedSpreadsheet->content); | ||
| } else { | ||
| $model->setAttribute('_spreadsheet', []); | ||
| } | ||
| }); | ||
|
|
||
| static::creating(function (Model $model) {}); | ||
|
|
||
| static::created(function (Model $model) { | ||
| $model->spreadsheetable()->create([ | ||
| 'content' => $model->_pendingSpreadsheetData ?? [], | ||
| 'locale' => app()->getLocale(), | ||
| ]); | ||
| }); | ||
|
|
||
| static::updating(function (Model $model) {}); | ||
|
|
||
| static::updated(function (Model $model) {}); | ||
|
|
||
| static::saving(function (Model $model) { | ||
| if (!$model->exists) { | ||
| $model->_pendingSpreadsheetData = array_merge($model->_pendingSpreadsheetData, $model->_spreadsheet ?? []); | ||
| } else if ($model->_spreadsheet) { | ||
| $locale = app()->getLocale(); | ||
| // Update or create the spreadsheet translation via the relationship | ||
| $model->spreadsheetable()->updateOrCreate( | ||
| ['locale' => $locale], | ||
| ['content' => $model->_spreadsheet] | ||
| ); | ||
| } | ||
| $model->offsetUnset('_spreadsheet'); | ||
| }); | ||
|
|
||
| static::saved(function (Model $model) {}); | ||
|
|
||
| static::restoring(function (Model $model) {}); | ||
|
|
||
| static::restored(function (Model $model) {}); | ||
|
|
||
| static::replicating(function (Model $model) {}); | ||
|
|
||
| static::deleting(function (Model $model) {}); | ||
|
|
||
| static::deleted(function (Model $model) {}); | ||
|
|
||
| static::forceDeleting(function (Model $model) {}); | ||
|
|
||
| static::forceDeleted(function (Model $model) {}); | ||
| } | ||
|
|
||
| /** | ||
| * Laravel hook to initialize the trait | ||
| * | ||
| * @return void | ||
| */ | ||
| public function initializeHasSpreadsheetable(): void | ||
| { | ||
| $spreadsheetableFields = ['_spreadsheet']; | ||
| $this->mergeFillable($spreadsheetableFields); | ||
| } | ||
|
|
||
| public function spreadsheetable(): \Illuminate\Database\Eloquent\Relations\MorphMany | ||
| { | ||
| return $this->morphMany(\Unusualify\Modularity\Entities\Spreadsheet::class, 'spreadsheetable'); | ||
| } | ||
|
|
||
| // protected function handleTranslatedSpreadsheet($data){ | ||
|
|
||
| // } | ||
|
|
||
| } |
This file contains hidden or 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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Unusualify\Modularity\Entities\Translations; | ||
|
|
||
| use Unusualify\Modularity\Entities\Spreadsheet; | ||
| use Unusualify\Modularity\Entities\Model; | ||
|
|
||
| class SpreadsheetTranslation extends Model | ||
| { | ||
| protected $baseModuleModel = Spreadsheet::class; | ||
|
|
||
| protected $fillable = ['content', 'locale']; | ||
|
|
||
| protected $casts = [ | ||
| 'content' => 'array', | ||
| ]; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.