Skip to content

Commit

Permalink
Merge pull request #7 from queents/dev
Browse files Browse the repository at this point in the history
fix media process on edit
  • Loading branch information
3x1io authored Dec 19, 2022
2 parents 54b3b9c + 2011953 commit bd7b325
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 5 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Database/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion Providers/BaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class BaseServiceProvider extends ServiceProvider
*/
public function boot()
{
VILT::registerMenu(Menu::make('Dashboard')->label('global.dashboard')->icon('bx bx-home')->route('dashboard')->sort(0));
VILT::registerMenu(Menu::make('Profile')->label('global.profile')->icon('bx bxs-user')->key('profile')->route('profile.show'));
$this->registerConfig();
$this->loadViewsFrom(module_path($this->moduleName, 'Resources/views'), 'base');
Expand Down
Binary file added Services/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions Services/Concerns/HasResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Modules\Base\Services\Concerns;

trait HasResource
{
/**
* @var ?array
* @example 'groupId'
*/
public ?array $resource = null;

/**
* @param ?string $resource
* @return $this
*/
public function resource(?string $resource): static
{
$data = app($resource)->query(request(), $this->rows, false);
$this->resource = app($resource)->response($this->rows, $data, app($resource)->table);
return $this;
}
}
3 changes: 2 additions & 1 deletion Services/Resource/Concerns/Pages/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public function create(Request $request): \Inertia\Response
$rows = $this->rows();
return Render::make(ucfirst(Str::camel($this->table)).'/Create')->module($this->module)->data([
"rows" => $rows,
"url" => $this->table
"url" => $this->table,
"trans" => $this->loadTranslations()
])->render();
}
}
3 changes: 2 additions & 1 deletion Services/Resource/Concerns/Pages/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function edit(Request $request, $id): \Inertia\Response
return Render::make(ucfirst(Str::camel($this->table)).'/Edit')->module($this->module)->data([
"rows" => $rows,
"record" => $record,
"url" => $this->table
"url" => $this->table,
"trans" => $this->loadTranslations()
])->render();
}
}
3 changes: 2 additions & 1 deletion Services/Resource/Concerns/Pages/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public function view(Request $request, $id){
return Render::make(ucfirst(Str::camel($this->table)).'/View')->module($this->module)->data([
"rows" => $rows,
"record" => $record,
"url" => $this->table
"url" => $this->table,
"trans" => $this->loadTranslations()
])->render();
}
}
2 changes: 1 addition & 1 deletion Services/Resource/Concerns/Process/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function processMediaOnUpdate(Request $request, $record): void
}
}
}
else if(empty($request->get($field->name))){
else if($field->edit && empty($request->get($field->name))){
$record->clearMediaCollection($field->name);
}
}
Expand Down
22 changes: 22 additions & 0 deletions Services/Rows/RelationManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Modules\Base\Services\Rows;

use Modules\Base\Services\Concerns\HasResource;
use Modules\Base\Services\Rows\Abstracts\Base;

class RelationManager extends Base
{
use HasResource;

public string $vue = "ViltRelationManager.vue";

/**
* @param string $name
* @return static
*/
public static function make(string $name): self
{
return (new self)->name($name);
}
}
Binary file added Tests/.DS_Store
Binary file not shown.

0 comments on commit bd7b325

Please sign in to comment.