Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Oct 24, 2023
1 parent 9d9ccbc commit 2508e7a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
8 changes: 7 additions & 1 deletion src/Fields/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(string $label, string $modelAttribute = null, Closur
parent::__construct($label, $modelAttribute, $relation);

$this->setAttribute('multiple', true);
$this->name($this->modelAttribute.'[]');
}

/**
Expand Down Expand Up @@ -98,6 +97,13 @@ public function toOption(Request $request, Model $model, Model $related): array

$option = parent::toOption($request, $model, $related);

$option['attrs']['name'] = sprintf(
'%s[%s][%s]',
$this->getAttribute('name'),
$related->getKey(),
$this->getRelation($model)->getRelatedPivotKeyName()
);

$option['fields'] = is_null($this->pivotFieldsResolver)
? new Fields()
: call_user_func_array($this->pivotFieldsResolver, [$request, $model, $related]);
Expand Down
8 changes: 0 additions & 8 deletions src/Fields/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ public function resolveOptions(Request $request, Model $model): array
->all();
}

/**
* {@inheritdoc}
*/
public function newOption(Model $related, string $label): Option
{
return new Option($related, $label);
}

/**
* Set the storage resolver callback.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MediaController extends Controller
*/
public function __invoke(Request $request): JsonResponse
{
$resource = $request->route('resource');
$resource = $request->route('_resource');

$field = $request->route('field');

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/RepeaterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RepeaterController extends Controller
*/
public function __invoke(Request $request): JsonResponse
{
$resource = $request->route('resource');
$resource = $request->route('_resource');

$field = $request->route('field');

Expand Down
17 changes: 8 additions & 9 deletions src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Http\Request;
use Illuminate\Routing\Events\RouteMatched;
use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Gate;
Expand Down Expand Up @@ -94,6 +93,14 @@ public function getUriKey(): string
return $this->getKey();
}

/**
* Get the route parameter name.
*/
public function getRouteParameterName(): string
{
return '_resource';
}

/**
* Get the name.
*/
Expand Down Expand Up @@ -285,14 +292,6 @@ public function registerRoutes(Request $request, Router $router): void
});
}

/**
* Handle the route matched event.
*/
public function routeMatched(RouteMatched $event): void
{
//
}

/**
* Get the instance as an array.
*/
Expand Down

0 comments on commit 2508e7a

Please sign in to comment.