File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1
1
<?php namespace SistemApi \Model ;
2
2
3
+ use Illuminate \Support \Collection ;
3
4
use SistemApi \Model \Base \Model ;
4
5
5
6
/**
16
17
* // model
17
18
*
18
19
* @property UrunKategori kategori
20
+ * @property Collection|Resim[] resimler
19
21
*
20
22
*/
21
23
class Urun extends Model
@@ -24,6 +26,13 @@ public function __set($key, $value)
24
26
{
25
27
switch ($ key ) {
26
28
case 'kategori ' : $ value = new UrunKategori ($ value ); break ;
29
+ case 'resimler ' :
30
+ $ collection = new Collection ();
31
+ foreach ($ value as $ item ) {
32
+ $ collection ->push (new Resim ($ item ));
33
+ }
34
+ $ value = $ collection ;
35
+ break ;
27
36
}
28
37
29
38
parent ::__set ($ key , $ value );
Original file line number Diff line number Diff line change 10
10
use SistemApi \Model \Response \Urun \SiparisPagedResponse ;
11
11
use SistemApi \Model \Response \UrunKategoriPagedResponse ;
12
12
use SistemApi \Model \Response \UrunPagedResponse ;
13
+ use SistemApi \Model \Urun ;
13
14
use SistemApi \Model \Urun \SiparisAdres ;
14
15
use SistemApi \Model \UrunKategori ;
15
16
use SistemApi \Model \UrunOzellikGrup ;
@@ -46,6 +47,29 @@ public function liste(UrunListeAyar $ayar = null)
46
47
throw new UnknownException ($ response );
47
48
}
48
49
50
+ /**
51
+ * @param int $id
52
+ * @return Urun
53
+ *
54
+ * @throws NotFoundException
55
+ * @throws UnauthorizedException
56
+ */
57
+ public function get ($ id )
58
+ {
59
+ // response alalım
60
+ $ response = $ this ->api ->get ('/urun/detay/ ' . $ id );
61
+
62
+ // durum koduna göre işlem yapalım
63
+ switch ($ response ->code ) {
64
+
65
+ case 200 : return new Urun ($ response ->body );
66
+ case 401 : throw new UnauthorizedException ($ response ->body ->mesaj );
67
+ case 404 : throw new NotFoundException ($ response ->body ->mesaj );
68
+ }
69
+
70
+ throw new UnknownException ($ response );
71
+ }
72
+
49
73
/**
50
74
* @deprecated use listeKategori
51
75
*
You can’t perform that action at this time.
0 commit comments