0
Context:
When trying to delete the object Structure checklist the following error occurred:  mb_strpos() expects parameter 1 to be string, object given
How to solve this problem?
Information from Dev Tools:
Javascript file:  (checklistEstrutura-index.js)
$(document).on('click', '#btnExcluirChecklistEstrutura', function () {
    $('#idChecklistEstruturaNome').text($(this).data('id'));
    $('#idChecklistEstrutura').val($(this).data('id'));
});
//Ajax para remover um  checklist de estrutura, e atualizar a página após a ação
$('.removeChecklistEstrutura').click(function () {
    var data_id = $('#idChecklistEstrutura').val();
    $.ajaxSetup({
        headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    }); 
    $.ajax({
        url:  "/checklistsEstruturas/remove",
        type: "POST",
        data: {id: data_id}
    }).done(function (response) {
        console.log(response);
        if (response.success) {  
         $('.message').text("Sucesso ao excluir");
         $('.message').show(); 
        setTimeout(function(){
                location.reload();
            }, 500); 
        }
        else {
           alert(response.error);
        }   
    }).fail(function () {
        $('.message').text("Erro ao excluir");
    });
    return false;
});
//Evento que preencherá o modal View do Checklist de Estrutura
$(document).on('click', '.btnViewChecklistEstrutura',function () {
    $('#modalViewId').val(($(this).data('id')));
    $('#modalViewModelo').val(($(this).data('modelo')));
    $('#modalViewItem').val(($(this).data('item')));
});
Remove method from the Checkliststructurecontroller.php class
  //Este método remove o contato do checklist de Estrutura
   public function remove(Request $request)
   {
     $checklistEstrutura = ChecklistEstrutura::find($request->id);
      if (!$checklistEstrutura)
       return response()
                ->json(['error' => 'not_found'], 404);
      $response =  $checklistEstrutura->deletar($checklistEstrutura);  
      if($response['success'])
      {
       return response()
               ->json(['success' => $response['message']], 200);  
      }else
      {
            // Caso não delete, informa um erro inesperado
       return redirect()
                ->json(['error' => $response['message']], 500);        
      } 
   }
Template: "delete method" (Checkliststructure.php)
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use DB;
use SoftDeletes;
class ChecklistEstrutura extends Model
{
    protected $table = "checklist_estrutura";
    protected $primaryKey = ['Estrutura_id'];
    public $incrementing = false;
    public $timestamps = false; 
    public function checklistEstrutura()
    {
      return $this->belongsTo('App\Models\ChecklistEstrutura', 'Estrutura_id','modelo_id', 'itens_id');
    }
    //Este método salva os dados do Checklist da Estrutura
      public function salvar(ChecklistEstrutura $checklistEstrutura) : Array
      {
         $checklistEstrutura = $this->save();
           if($checklistEstrutura){
              return[
                  'success' => true,
                  'message' => 'Sucesso ao cadastrar'
              ];   
          }
          else{
              return[
                  'success' => false,
                  'message' => 'Falha ao cadastrar'
              ]; 
          }
      }
      //Este método remove os dados do Checklist da Estrutura
    public function deletar(ChecklistEstrutura $checklistEstrutura) : Array
    {
        $checklistEstrutura = $this->delete();
        if($checklistEstrutura){
            return[
                'success' => true,
                'message' => 'Sucesso ao excluir'
            ];   
        }
        else{
            return[
                'success' => false,
                'message' => 'Falha ao excluir'
            ]; 
        }
    }
  //Este método atualiza os dados do  Checklist da Estrutura
  public function alterar(ChecklistEstrutura $checklistEstrutura) : Array
  {
    $checklistEstrutura = $this->save();
      if($checklistEstrutura){
          return[
              'success' => true,
              'message' => 'Sucesso ao atualizar'
          ];   
      }
      else{
          return[
              'success' => false,
              'message' => 'Falha ao atualizar'
          ]; 
      }
  }
}
Routes of the Checkliststructure: (web php.)
//Gerenciar dados do ChecklistEstrutura
$this->group(['middleware' => ['auth'], 'namespace' =>'admin','prefix'=>'checklistsEstruturas'], function(){
    //Inicio das Rotas de gerenciar os checklistsEstruturas
    $this->post('cadastro','ChecklistEstruturaController@cadastro')->name('checklistEstrutura.cadastro');
    $this->post('checklistEstrutura','ChecklistEstruturaController@consulta')->name('checklistEstrutura.consulta');
    $this->post('atualiza', 'ChecklistEstruturaController@atualiza')->name('checklistEstrutura.atualiza');
    $this->post('remove','ChecklistEstruturaController@remove')->name('checklistEstrutura.remove');
    $this->get('edita/{id}','ChecklistEstruturaController@edita')->name('checklistEstrutura.edita');
    $this->get('novo','ChecklistEstruturaController@novo')->name('checklistEstrutura.novo');
    $this->get('checklistEstrutura','ChecklistEstruturaController@index')->name('admin.checklistEstrutura');
   //Final das Rotas de gerenciar dados do checklistsEstruturas
});
Information from DEV TOOLS: (trying to delete the object with id = 9)
 Aba: Param
 Aba: Response



Hello, Ruama. Good afternoon. Try to access your log folder. The file will be closer to that:
storage/logs/laravel-*. There will give you all the backtrace (all the paths where the execution took place until the error). It seems that you passed a wrong information to some method that expects string.– Wallace Maxters
the line
redirect()->json()is not wrong? would not beresponse()->json()?– Wallace Maxters
Here
public function remove(Request $request)you do$checklistEstrutura = ChecklistEstrutura::find($request->id);but on your route, which is a post, you don’t have a$request->id:$this->post('remove','ChecklistEstruturaController@remove')->name('checklistEstrutura.remove');– thxmxx
@thxmxx has yes.
– Wallace Maxters