File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Serverfireteam \Panel ;
3
3
4
+ use Carbon \Carbon ;
4
5
use Illuminate \Database \Eloquent \Model ;
5
6
6
7
class Link extends Model {
@@ -33,16 +34,31 @@ public static function getMainUrls($forceRefresh = false)
33
34
}
34
35
return self ::$ cache ['main_urls ' ];
35
36
}
37
+
38
+ /**
39
+ * insert new link. this function don't need to use save()
40
+ * @param $url
41
+ * @param $label
42
+ * @param $visibility
43
+ * @param bool $checkExistence
44
+ */
36
45
public function addNewLink ($ url , $ label , $ visibility , $ checkExistence = false ) // getAndSave(
37
46
{
38
47
if ($ checkExistence && $ this ->isLinkExist ($ url , $ label ))
39
48
{
40
49
return ;
41
50
}
42
- $ this ->url = $ url ;
43
- $ this ->display = $ label ;
44
- $ this ->show_menu = $ visibility ;
45
- $ this ->save ();
51
+ $ now = Carbon::now ()->toDateTimeString ();
52
+ $ data = array (
53
+ array (
54
+ 'url ' =>$ url ,
55
+ 'display ' =>$ label ,
56
+ 'show_menu ' =>$ visibility ,
57
+ 'created_at ' => $ now ,
58
+ 'updated_at ' => $ now
59
+ )
60
+ );
61
+ Link::insert ($ data );
46
62
}
47
63
48
64
/**
You can’t perform that action at this time.
0 commit comments