Skip to content

Commit 5f8a671

Browse files
committed
gallery module
1 parent bdf788d commit 5f8a671

File tree

5 files changed

+315
-86
lines changed

5 files changed

+315
-86
lines changed

src/SistemApi/Model/Base/Model.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Illuminate\Contracts\Support\Arrayable;
55
use Illuminate\Contracts\Support\Jsonable;
66
use Illuminate\Support\Collection;
7+
use SistemApi\Model\Galeri;
78
use SistemApi\Model\Ilce;
89
use SistemApi\Model\Kullanici;
910
use SistemApi\Model\ParaBirim;
@@ -23,7 +24,8 @@ class Model implements Arrayable, Jsonable
2324
'ilce' => Ilce::class,
2425
'urun' => Urun::class,
2526
'para_birim' => ParaBirim::class,
26-
'kullanici' => Kullanici::class
27+
'kullanici' => Kullanici::class,
28+
'galeri' => Galeri::class
2729
];
2830

2931
private $array_models = [

src/SistemApi/Model/Galeri.php

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,48 @@
11
<?php namespace SistemApi\Model;
22

3-
use Carbon\Carbon;
4-
5-
class Galeri
3+
use Illuminate\Support\Collection;
4+
use SistemApi\Model\Base\Model;
5+
6+
/**
7+
* @property int id
8+
* @property string baslik
9+
* @property string rbaslik
10+
* @property string kodu
11+
* @property int site_id
12+
* @property int tur_id
13+
* @property int varsayilan_icerik_id
14+
*
15+
* // modeller
16+
*
17+
* @property GaleriIcerik varsayilanIcerik
18+
* @property Collection|GaleriIcerik[] icerikler
19+
*/
20+
class Galeri extends Model
621
{
7-
public $id;
8-
public $baslik;
9-
public $rbaslik;
10-
public $kodu;
11-
public $site_id;
12-
public $haber_id;
13-
public $tur_id;
14-
public $varsayilan_icerik_id;
22+
const TUR_RESIM = 1;
23+
const TUR_VIDEO = 2;
1524

16-
/**
17-
* @var Carbon
18-
*/
19-
public $created_at;
20-
21-
/**
22-
* @var Carbon
23-
*/
24-
public $updated_at;
25-
26-
/**
27-
* @var GaleriIcerik
28-
*/
29-
public $varsayilanIcerik;
30-
31-
/**
32-
* @var GaleriIcerik[]
33-
*/
34-
public $icerikler = [];
35-
36-
/**
37-
* @param \stdClass $item
38-
*/
39-
public function __construct($item)
25+
public function __set($key, $value)
4026
{
41-
if (isset($item->id)) $this->id = $item->id;
42-
if (isset($item->baslik)) $this->baslik = $item->baslik;
43-
if (isset($item->rbaslik)) $this->rbaslik = $item->rbaslik;
44-
if (isset($item->kodu)) $this->kodu = $item->kodu;
45-
if (isset($item->site_id)) $this->site_id = $item->site_id;
46-
if (isset($item->haber_id)) $this->haber_id = $item->haber_id;
47-
if (isset($item->tur_id)) $this->tur_id = $item->tur_id;
48-
if (isset($item->varsayilan_icerik_id)) $this->varsayilan_icerik_id = $item->varsayilan_icerik_id;
49-
if (isset($item->created_at)) $this->created_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at);
50-
if (isset($item->updated_at)) $this->updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
51-
52-
if (isset($item->varsayilanIcerik)) {
53-
$this->varsayilanIcerik = new GaleriIcerik($item->varsayilanIcerik);
27+
switch ($key) {
28+
case 'varsayilanIcerik':
29+
$value = new GaleriIcerik($value);
30+
break;
31+
case 'icerikler':
32+
$collection = new Collection();
33+
foreach ($value as $item) {
34+
$collection->push(new GaleriIcerik($item));
35+
}
36+
$value = $collection;
37+
break;
5438
}
5539

56-
if (isset($item->icerikler)) {
57-
foreach ($item->icerikler as $icerik) {
58-
$this->icerikler[] = new GaleriIcerik($icerik);
59-
}
60-
}
40+
parent::__set($key, $value);
6141
}
6242

6343
/**
44+
* @deprecated use tur_id
45+
*
6446
* @return bool
6547
*/
6648
public function isResimGalerisi()

src/SistemApi/Model/GaleriIcerik.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
<?php namespace SistemApi\Model;
22

3-
use Carbon\Carbon;
3+
use SistemApi\Model\Base\Model;
44

5-
class GaleriIcerik
5+
/**
6+
* @property int id
7+
* @property string aciklama
8+
* @property string kodu
9+
* @property int galeri_id
10+
* @property string embed_kodu
11+
*
12+
* // diğer
13+
*
14+
* @property string resim_adresi_orjinal
15+
* @property string resim_adresi_kirpilmis
16+
*
17+
* // modeller
18+
*
19+
* @property Galeri galeri
20+
* @property Resim imageOriginal
21+
* @property Resim imageCropped
22+
*/
23+
class GaleriIcerik extends Model
624
{
7-
public $id;
8-
public $aciklama;
9-
public $kodu;
10-
public $galeri_id;
11-
public $embed_kodu;
12-
public $created_at;
13-
public $updated_at;
14-
15-
// diğer
16-
17-
public $resim_adresi_orjinal;
18-
public $resim_adresi_kirpilmis;
19-
20-
/**
21-
* @param \stdClass $item
22-
*/
23-
public function __construct($item)
25+
public function __set($key, $value)
2426
{
25-
if (isset($item->id)) $this->id = $item->id;
26-
if (isset($item->aciklama)) $this->aciklama = $item->aciklama;
27-
if (isset($item->kodu)) $this->kodu = $item->kodu;
28-
if (isset($item->galeri_id)) $this->galeri_id = $item->galeri_id;
29-
if (isset($item->embed_kodu)) $this->embed_kodu = $item->embed_kodu;
30-
if (isset($item->created_at)) $this->created_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at);
31-
if (isset($item->updated_at)) $this->updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $item->updated_at);
32-
33-
// diğer
27+
switch ($key) {
28+
case 'imageOriginal':
29+
case 'imageCropped':
30+
$value = new Resim($value);
31+
break;
32+
}
3433

35-
if (isset($item->resim_adresi_orjinal)) $this->resim_adresi_orjinal = $item->resim_adresi_orjinal;
36-
if (isset($item->resim_adresi_kirpilmis)) $this->resim_adresi_kirpilmis = $item->resim_adresi_kirpilmis;
34+
parent::__set($key, $value);
3735
}
3836
}

src/SistemApi/Model/MansetKategori.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getSettingCropperAspectRatioHeight()
2727
{
2828
return isset($this->settings->cropper->aspectRatio->height) ?
2929
$this->settings->cropper->aspectRatio->height :
30-
850;
30+
350;
3131
}
3232

3333
public function getSettingCropperMinCropBoxWidth()
@@ -41,6 +41,6 @@ public function getSettingCropperMinCropBoxHeight()
4141
{
4242
return isset($this->settings->cropper->minCropBox->height) ?
4343
$this->settings->cropper->aspectRatio->height :
44-
850;
44+
350;
4545
}
4646
}

0 commit comments

Comments
 (0)