Laravel -records in the table are being deleted at the end of the import -




i importing data wordpress database database use laravel project. doing import this:

public function all() {     $posts = post::where('post_status', 'publish')->get();     foreach ($posts $post ) {         $this->createcontent($post->id);     } }  private function createcontent($post)     {         $ctid = contenttype::where('name', $post->post_type)->first()->id;         $inventory = inventory::where('cms_id', $post->id)->first()->id;          $content = content::updateorcreate(             ['cms_id' => $inventory->remote_id],             [                 'ct_id'     => $ctid,                 'title'     => $post->post_title,                 'slug'      => str_slug($post->post_title, '-'),                 'excerpt'   => $post->post_excerpt,                 'body'      => $this->formatbodyimages($post->post_content),                 'password'  => $post->post_password,                 'parent_id' => $post->post_parent,             ]);          $this->updateinventory($inventory, $content);         $this->deletecontentolddata($content);         $this->updateorcreatesupplementaries($post, $content); 

deletecontentolddata($content) deleting old records posts importing if exist, , think might problem:

private function deletecontentolddata($content) {     if (count($content->supplementary) || is_null($content->supplementary)){       $content->supplementary()->delete();     }     if (count($content->files) || is_null($content->files)){       $content->files()->delete();     }     if (count($content->taxonomies) || is_null($content->taxonomies)){       $content->taxonomies()->delete();     }     if (count($content->featured) || is_null($content->featured)){       $content->featured()->delete();     } } 

the problem have that, when trying import posts wp database this, in table taxonomicals, model have setup relationships this:

public function content() {     return $this->morphedbymany('app\content', 'taxonomical'); }  public function file() {     return $this->morphedbymany('app\file', 'taxonomical'); } public function term() {     return $this->hasone('app\taxonomy', 'id', 'taxonomy_id'); }  

the data being imported fine until end, when have 1800 records in taxonomicals table, when import finished of records reason deleted , left 8 records in table. have same code locally , running same import, , there works fine. have run migrations know have same databases locally , on live server, not sure wrong on live server's database?





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -