lorisleiva / laravel-actions

⚡️ Laravel components that take care of one specific task
https://laravelactions.com
MIT License
2.49k stars 121 forks source link

Added ajax response method. #194

Closed georgemjohn closed 2 years ago

georgemjohn commented 2 years ago

Added ajax response method

leandrodiogenes commented 2 years ago

Im sorry but what is the difference of an ajax response and json response?

Apparently laravel treats it the same way.

namespace Illuminate\Http\Concerns;

use Illuminate\Support\Str;

trait InteractsWithContentTypes
{
    ...
    public function expectsJson()
    {
        return ($this->ajax() && ! $this->pjax() && $this->acceptsAnyContentType()) || $this->wantsJson();
    }
   ...
}
leandrodiogenes commented 2 years ago

Please create a test. Simulate an action with both methods in the same class. jsonResponse and ajaxResponse. I believe one will conflict with the other because both are treated the same by laravel

lorisleiva commented 2 years ago

Hi there 👋

I agree with @leandrodiogenes and struggle to see the value in this PR.

If you wish to try again, please open a new PR with a clear description of why this would improve the package with some tests to make sure it works.

Thank you for your understanding.