Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. public function up()
  2. {
  3. Schema::create('parceiros_table', function (Blueprint $table) {
  4. $table->string('parc_cpf_cnpj', 18)->nullable();
  5. $table->string('parc_ie', 20)->default("");
  6. $table->string('parc_razao_social', 160)->default("");
  7. $table->string('parc_nm_fantasia', 160)->default("");
  8. $table->string('parc_email', 160)->default("");;
  9. $table->string('parc_tel_comercial', 15)->default("");
  10. $table->string('parc_bairro', 200)->default("");
  11. $table->string('parc_cep', 10)->default("");
  12. $table->string('parc_end', 200)->default("");
  13. $table->string('parc_cidade', 200)->default("");
  14. $table->string('parc_uf', 2)->default("");
  15. $table->integer('parc_user_id')->unsigned();
  16. $table->foreign('parc_user_id')->references('id')->on('users');
  17. $table->primary(['parc_cpf_cnpj']);
  18. $table->rememberToken();
  19. $table->timestamps();
  20. $table->softDeletes();
  21. });
  22. }
  23.  
  24. use Notifiable;
  25. use SoftDeletes;
  26.  
  27. protected $dates = ['deleted_at'];
  28.  
  29. protected $table = 'parceiros_table';
  30. protected $primaryKey = 'parc_cpf_cnpj';
  31.  
  32. protected $fillable = [
  33. 'parc_cpf_cnpj', 'parc_razao_social', 'parc_nm_fantasia',
  34. 'parc_email', 'parc_tel_comercial', 'parc_bairro', 'parc_cep', 'parc_end', 'parc_cidade',
  35. 'parc_uf', 'parc_ie', 'parc_user_id',
  36. ];
  37.  
  38. $emit = Parceiro::where('parc_cpf_cnpj','=',$stark_explode[0]->NFe->infNFe->emit->CNPJ)->get()->first();
  39.  
  40. if($emit == null){
  41. $emit = new Parceiro();
  42. $emit->parc_cpf_cnpj = $stark_explode[0]->NFe->infNFe->emit->CNPJ;
  43. if(is_null($emit->parc_razao_social)){
  44. $emit->parc_razao_social = "";
  45. }else{
  46. $emit->parc_razao_social = $stark_explode[0]->NFe->infNFe->emit->xNome;
  47. }
  48. if(is_null($emit->parc_nm_fantasia)){
  49. $emit->parc_nm_fantasia = "";
  50. }else{
  51. $emit->parc_nm_fantasia = $stark_explode[0]->NFe->infNFe->emit->xFant;
  52. }
  53. $emit->parc_ie = $stark_explode[0]->NFe->infNFe->emit->IE;
  54. $emit->parc_end = $stark_explode[0]->NFe->infNFe->emit->enderDest->xLgr;
  55. $emit->parc_bairro = $stark_explode[0]->NFe->infNFe->emit->enderEmit->xBairro;
  56. $emit->parc_cidade = $stark_explode[0]->NFe->infNFe->emit->enderEmit->xMun;
  57. $emit->parc_uf = $stark_explode[0]->NFe->infNFe->emit->enderEmit->UF;
  58. $emit->parc_user_id = Auth::user()->id;
  59. $this->toUpper($emit);
  60.  
  61. dd($stark_explode[0]->NFe->infNFe->emit->CNPJ);
  62.  
  63. $emit->save();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement