@@ -35,7 +35,7 @@ public static function boot()
35
35
{
36
36
parent ::boot ();
37
37
self ::saving (function ($ model ) {
38
- $ model ->created_by = \Auth::user ()->id ;
38
+ if (!\Auth:: guest ()) $ model ->created_by = \Auth::user ()->id ;
39
39
$ model ->setExtraFields ();
40
40
});
41
41
}
@@ -64,15 +64,27 @@ public function isSubAdmin()
64
64
65
65
public function setExtraFields ()
66
66
{
67
- $ this ->zip_code = Input::post ('zip_code ' );
68
- $ this ->city_id = Input::post ('city_id ' );
69
- $ this ->address = Input::post ('address ' );
70
- $ this ->neighborhood = Input::post ('neighborhood ' );
71
- $ this ->is_company = Input::post ('is_company ' ) == "true " ;
72
- $ this ->cpf_cnpj = Input::post ('cpf_cnpj ' );
73
- $ this ->accession = \Helper::moneyToFloat (Input::post ('accession ' ));
74
- $ this ->payment_day = Input::post ('payment_day ' );
75
- $ this ->payment_monthy = \Helper::moneyToFloat (Input::post ('payment_monthy ' ));
67
+ if ($ zip_code = Input::post ('zip_code ' ))
68
+ $ this ->zip_code = $ zip_code ;
69
+ if ($ city_id = Input::post ('city_id ' ))
70
+ $ this ->city_id = $ city_id ;
71
+ if ($ address = Input::post ('address ' ))
72
+ $ this ->address = $ address ;
73
+ if ($ neighborhood = Input::post ('neighborhood ' ))
74
+ $ this ->neighborhood = $ neighborhood ;
75
+ if ($ is_company = Input::post ('is_company ' ))
76
+ $ this ->is_company =$ is_company ;
77
+ if ($ cpf_cnpj = Input::post ('cpf_cnpj ' ))
78
+ $ this ->cpf_cnpj = $ cpf_cnpj ;
79
+ if ($ accession = Input::post ('accession ' ))
80
+ $ this ->accession = \Helper::moneyToFloat ($ accession );
81
+ if ($ payment_day = Input::post ('payment_day ' ))
82
+ $ this ->payment_day = $ payment_day ;
83
+ if ($ payment_monthy = Input::post ('payment_monthy ' ))
84
+ $ this ->payment_monthy = \Helper::moneyToFloat ($ payment_monthy );
85
+ if ($ validation = Input::post ('validation ' )) {
86
+ $ this ->validation = \Helper::parseDate ($ validation );
87
+ }
76
88
}
77
89
78
90
public function city ()
@@ -84,4 +96,10 @@ public function contacts()
84
96
{
85
97
return $ this ->hasMany ('App\Contact ' , 'id ' , 'user_id ' );
86
98
}
99
+
100
+ public function invalid ()
101
+ {
102
+ if (!$ this ->validation ) return false ;
103
+ return strtotime ($ this ->validation ) < strtotime (date ("Y-m-d H:i:s " ));
104
+ }
87
105
}
0 commit comments