Replies: 2 comments 4 replies
-
Depends whats your model at this point when you render the content and buttons. Since the query or the table content is not in the code snippets, it's difficult to say if model is the review or product object. Maybe it's just something like: $model->review->id |
Beta Was this translation helpful? Give feedback.
-
I noticed that /**
* @param \Orchid\Screen\Screen $screen
* @param string $method
* @param array $httpQueryArguments
*
* @throws \ReflectionException
*
* @return array
*/
public function resolveScreen(Screen $screen, string $method, array $httpQueryArguments = []): array
{
$parameters = (new ReflectionClass($screen))->getMethod($method)->getParameters();
$arguments = collect($httpQueryArguments);
return collect($parameters)
->map(function (ReflectionParameter $parameter) use (&$arguments) {
return $this->bind($parameter, $arguments);
})
->all();
} In [
0 => $id
] and in [
0 => {productId},
1 => 'deleteReview',
'id' => {reviewId that I pass in Button `parameters()` method}
] So If I add two more parameters to /**
* @param int $productId
* @param string $method
* @param int $reviewId
* @return void
*/
public function deleteReview(int $productId, string $method, int $reviewId): void
{
TelegramUserReview::destroy($reviewId);
} But I dont think it's clear code. Do you think the latter approach is a good idea? P.s. I just tested this. It works. All I had to do was add |
Beta Was this translation helpful? Give feedback.
-
I have URL like http://localhost/admin/product/137/reviews.
In this screen I operate with Review entities, not Product entity.
So when I try to (CR)UD Review entity (with ID 465 for example) I get Product ID (137 from URL) in my methods.
Screen looks like this.
For control buttons I have code:
As you can see I pass TelegramUserReview ID as parameter for
deleteReview
method. But when I dump it I get 137 instead of 465.I am pretty sure that review ID is 465, not 137.
Also I have URL like http://localhost/admin/reviews. This URL uses the same screen.
Deleting the review works properly here. I mean I get correct review ID in
deleteReview
method.Same thing happens with Modals. I solved it by making hidden Input with review id, but it's too ugly solution.
Have you guys seen this in your code? How did you solve that?
Beta Was this translation helpful? Give feedback.
All reactions