kordix
247
6
Laravel

Create/update sql records without form

Posted 1 year ago by kordix

Can I make an update in SQL without < form >, input nor {{csrf_field}} , {{method_field('patch')}}?

I would like just to make controller which updates some record in database and execute it with < a href="{{route to that controller}}" > It may be just a button wchich executes the controller.

Now in controller I make Model::update([ 'record' => request('record') , and in the view I make a button inside form with hidden input with proper name and wanted value.

My controller would look like : Model::update(['record' => 'mywantedvalue']) , without request. Is there some way just to execute it?

Please sign in or create an account to participate in this conversation.