forked from dimitar032/LaravelQuiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
54 lines (41 loc) · 1.61 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
*************************************************************
MUTATORS USE SETATTRIBUTE
public function setFirstNameAttribute($value) { //first_name
$this->attributes['first_name'] = ucfirst($value);
}
*************************************************************
ACCESSORS USE GETATTRIBUTE
public function getCreatedAtAttribute($value){ //created_at
$formatted = new Carbon($value);
return $formatted->diffForHumans();
// return $formatted->format('d/m/Y G:i:s');
}
*************************************************************
SAVING NOTE WITH SPECIFIC CARD
$note = new Note;
$note->body =$request->body;
$card->notes()->save($note) // saving the specific card_id to that note
redirect back();
*************************************************************
VALIDATE ARRAYS
$this->validate($request,[
'email.*' => 'required|email'
],[
'email.*' => 'Please enter a valid email adress'
]);
return 'validation OK';
*************************************************************
ADDING VALID PERIOD FOR DATE ( +3 month TILL EXPIRE for example)
$created_at = '2010-01-08 12:34:56 ';
$d=strtotime($created_at. "+3 Months");
echo date("Y-m-d H:i:s", $d) . "<br>";
EACH MONDAY FOR 6 WEEKS
$startdate=strtotime("Saturday");
$enddate=strtotime("+6 weeks", $startdate);
while ($startdate < $enddate) {
echo date("M d", $startdate) . "<br>";
$startdate = strtotime("+1 week", $startdate);
}
*************************************************************
https://www.youtube.com/watch?v=v222Dtz7jm0
https://www.sitepoint.com/phpstorm-top-productivity-hacks-shortcuts/