Skip to content

Commit 406209a

Browse files
committed
manşet modülünde iyileştirmeler yapıldı.
1 parent e8c9f95 commit 406209a

File tree

9 files changed

+348
-38
lines changed

9 files changed

+348
-38
lines changed

src/SistemApi/ApiClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use SistemApi\Service\GaleriService;
77
use SistemApi\Service\GrupService;
88
use SistemApi\Service\HaberService;
9+
use SistemApi\Service\HeadlineService;
910
use SistemApi\Service\IlceService;
1011
use SistemApi\Service\IletisimMesajService;
1112
use SistemApi\Service\KullaniciService;

src/SistemApi/Model/Ayar/MansetKategoriListeAyar.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
class MansetKategoriListeAyar extends ListeAyar
66
{
7+
/**
8+
* @deprecated artık kullanılmıyacak
9+
*
10+
* @return ListeAyar
11+
*/
712
public function setOrderByAdi()
813
{
914
return parent::setOrderBy('adi');
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php namespace SistemApi\Model\Ayar;
2+
3+
use SistemApi\Model\Ayar\Base\ListeAyar;
4+
5+
class MansetListeAyar extends ListeAyar
6+
{
7+
/**
8+
* @var array
9+
*/
10+
private $categoryIds = [];
11+
12+
/**
13+
* @var string
14+
*/
15+
private $categoryCode;
16+
17+
/**
18+
* @return array
19+
*/
20+
public function toArray()
21+
{
22+
return array_merge(parent::toArray(), [
23+
'category_ids' => $this->categoryIds,
24+
'category_code' => $this->categoryCode
25+
]);
26+
}
27+
28+
/**
29+
* @return MansetListeAyar
30+
*/
31+
public function setOrderByRowOrder()
32+
{
33+
return $this->setOrderBy('sira');
34+
}
35+
36+
/**
37+
* @param int $categoryId
38+
* @return $this
39+
*/
40+
public function addCategoryId($categoryId)
41+
{
42+
$this->categoryIds[] = $categoryId;
43+
return $this;
44+
}
45+
46+
/**
47+
* @param int $categoryIds
48+
* @return MansetListeAyar
49+
*/
50+
public function setCategoryIds($categoryIds)
51+
{
52+
$this->categoryIds = $categoryIds;
53+
return $this;
54+
}
55+
56+
/**
57+
* @return int
58+
*/
59+
public function getCategoryIds()
60+
{
61+
return $this->categoryIds;
62+
}
63+
64+
/**
65+
* @param string $categoryCode
66+
* @return MansetListeAyar
67+
*/
68+
public function setCategoryCode($categoryCode)
69+
{
70+
$this->categoryCode = $categoryCode;
71+
return $this;
72+
}
73+
74+
/**
75+
* @return string
76+
*/
77+
public function getCategoryCode()
78+
{
79+
return $this->categoryCode;
80+
}
81+
}

src/SistemApi/Model/Base/Model.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class Model implements Arrayable, Jsonable
2727
];
2828

2929
private $array_models = [
30-
'dil_metalar'
30+
'dil_metalar',
31+
'languages'
3132
];
3233

3334
protected $attributes = [];
@@ -115,6 +116,17 @@ public function getValueByDilIdKey($dilId, $key)
115116
return null;
116117
}
117118

119+
public function getValueByLanguageIdKey($languageId, $key)
120+
{
121+
if ($this->languages instanceof Collection) {
122+
return isset($this->languages->get($languageId)[$key]) ?
123+
$this->languages->get($languageId)[$key] :
124+
null;
125+
}
126+
127+
return null;
128+
}
129+
118130
/**
119131
* Get the attributes that should be converted to dates.
120132
*

src/SistemApi/Model/Manset.php

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
<?php namespace SistemApi\Model;
22

3-
use Carbon\Carbon;
4-
5-
class Manset
3+
use Illuminate\Support\Collection;
4+
use SistemApi\Model\Base\Model;
5+
6+
/**
7+
* @property int id
8+
* @property string baslik @deprecated use title
9+
* @property string title
10+
* @property string link
11+
* @property int category_id
12+
*
13+
* // diğer
14+
*
15+
* @property string resim_adresi @deprecated use image_original_url
16+
* @property string image_original_url
17+
* @property string image_cropped_url
18+
* @property Collection languages
19+
*
20+
* // model
21+
*
22+
* @property MansetKategori category
23+
* @property Resim resim @deprecated use image_original
24+
* @property Resim image_original
25+
* @property Resim image_cropped
26+
*/
27+
class Manset extends Model
628
{
7-
public $id;
8-
public $baslik;
9-
public $link;
10-
11-
/**
12-
* @var Carbon
13-
*/
14-
public $created_at;
15-
16-
/**
17-
* @var Carbon
18-
*/
19-
public $updated_at;
20-
21-
// diğer
22-
23-
public $resim_adresi;
24-
25-
/**
26-
* @param \stdClass $item
27-
*/
28-
public function __construct($item)
29+
public function __set($key, $value)
2930
{
30-
if (isset($item->id)) $this->id = $item->id;
31-
if (isset($item->baslik)) $this->baslik = $item->baslik;
32-
if (isset($item->link)) $this->link = $item->link;
33-
if (isset($item->created_at)) $this->created_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at);
34-
if (isset($item->updated_at)) $this->updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
35-
36-
// diğer
37-
38-
if (isset($item->resim_adresi)) $this->resim_adresi = $item->resim_adresi;
31+
switch ($key) {
32+
case 'image_original':
33+
case 'image_cropped':
34+
$value = new Resim($value);
35+
break;
36+
case 'category':
37+
$value = new MansetKategori($value);
38+
break;
39+
}
40+
41+
parent::__set($key, $value);
3942
}
4043
}

src/SistemApi/Model/MansetKategori.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
/**
77
* @property int id
8-
* @property string adi
9-
* @property string kodu
8+
* @property string adi @deprecated
9+
* @property string title
10+
* @property string kodu @deprecated
11+
* @property string code
1012
* @property int site_id
11-
* @property Collection dil_metalar
13+
* @property Collection languages
1214
*/
1315
class MansetKategori extends Model
1416
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php namespace SistemApi\Model\Response;
2+
3+
use SistemApi\Model\Manset;
4+
use SistemApi\Model\Response\Base\PagedResponse;
5+
6+
class MansetPagedResponse extends PagedResponse
7+
{
8+
/**
9+
* @param \stdClass $item
10+
*/
11+
public function __construct($item)
12+
{
13+
parent::__construct($item, Manset::class);
14+
}
15+
16+
/**
17+
* @return Manset[]
18+
*/
19+
public function getMansetler()
20+
{
21+
return $this->kayitlar;
22+
}
23+
}

src/SistemApi/Service/ApiService.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,37 @@ public function post($uri, $data = [], $files = [])
6161
return Request::post($this->uri . $uri, $headers, $body);
6262
}
6363

64+
public function put($uri, $data = [], $files = [])
65+
{
66+
$headers = [
67+
'Accept' => 'application/json',
68+
'Content-Type' => empty($files) ? 'application/json' : 'multipart/form-data',
69+
'X-IFSISTEM-TOKEN' => $this->token,
70+
'X-IFSISTEM-DIL-ID' => $this->dilId
71+
];
72+
73+
$body = empty($files) ? Request\Body::Json($data) : Request\Body::multipart($data, $files);
74+
75+
return Request::put($this->uri . $uri, $headers, $body);
76+
}
77+
78+
/**
79+
* @param string $uri
80+
* @param array $query
81+
*
82+
* @return Response
83+
*/
84+
public function delete($uri, $query = [])
85+
{
86+
$headers = [
87+
'Accept' => 'application/json',
88+
'X-IFSISTEM-TOKEN' => $this->token,
89+
'X-IFSISTEM-DIL-ID' => $this->dilId
90+
];
91+
92+
return Request::delete($this->uri . $uri, $headers, $query);
93+
}
94+
6495
/**
6596
* @param int $dilId
6697
*/

0 commit comments

Comments
 (0)