Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW16 DDD (rework) #516

Open
wants to merge 2 commits into
base: VMeshavkin/hw16
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Envoy.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


@servers(['web' => ['[email protected]']])

@story('init')
git_init
composer
@endstory

@story('deploy')
git_clone
composer
@endstory

@task('git_init', ['on' => 'web'])
git clone --single-branch --branch VMeshavkin/hw16 https://github.com/otusteamedu/Laravel.git
@endtask

@task('git_clone', ['on' => 'web'])
cd Laravel
git pull origin VMeshavkin/hw16
@endtask

@task('composer', ['on' => 'web'])
cd Laravel
composer install
@endtask


@task('test', ['on' => 'web'])
php vendor/bin/phpunit
@endtask
8 changes: 0 additions & 8 deletions app/Advert/Domain/Model/Advert.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,4 @@ public function __construct
$this->date = $date;
}

public function publishAdvert() {}
public function viewAdvert() {}
public function editAdvert() {}
public function deleteAdvert() {}
public function archiveAdvert() {}
public function addMessageToAdvert() {}
public function editMessageInAdvert() {}
public function deleteMessageFromAdvert() {}
}
4 changes: 2 additions & 2 deletions app/Advert/Domain/Model/Entities/Owner.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __construct(string $name, string $phone, string $address, string
$this->zipCode = $zipCode;
}

public function getFullData(): string
public function getFullData(): array
{
return 'Name: '.$this->name.PHP_EOL.'tel:'.$this->phone.PHP_EOL.'Adr:'.$this->address;
return ['Name: '=>$this->name,'tel:'=>$this->phone,'Adr:'=>$this->address];
}
}
2 changes: 1 addition & 1 deletion app/Advert/Domain/Model/VO/Division.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace App\Advert\Domain\Model\Vo;
namespace App\Advert\Domain\Model\VO;


class Division
Expand Down
2 changes: 1 addition & 1 deletion app/Advert/Domain/Model/VO/Img.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace App\Advert\Domain\Model\Vo;
namespace App\Advert\Domain\Model\VO;


class Img
Expand Down
8 changes: 4 additions & 4 deletions app/Advert/Domain/Model/VO/Town.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace App\Advert\Domain\Model\Vo;
namespace App\Advert\Domain\Model\VO;


class Town
Expand All @@ -10,15 +10,15 @@ class Town
private $name;
private $state;

public function __construct($name, $state)
public function __construct(string $name, string $state)
{
$this->name = $name;
$this->state = $state;
}

public function getName(): string
public function getName(): array
{
return $this->name.'-'.$this->state;
return [$this->name, $this->state];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace App\Advert\Domain\Service;


interface AdvertOperationService
interface AdvertOperation
{

public function publishAdvert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
namespace App\Advert\Infrastructure\Repository;


use App\Advert\Domain\Service\AdvertOperationService;
use App\Models\Advert;
use App\Services\Adverts\Repositories\AdvertRepositoryInterface;
use App\Advert\Domain\Service\AdvertOperation;

class AdvertOperationEloquentRepository implements AdvertOperationService
class AdvertOperationEloquentRepository implements AdvertOperation
{


Expand Down Expand Up @@ -54,6 +52,3 @@ public function deleteMessageFromAdvert()
}


//Все что связано с модулями (swiftmailer, eloquent, ) можно реализовать через срвисы/репозитории,
// тем самым можно отвязаться от конкретных модулей и базы данных
//
6 changes: 3 additions & 3 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function create()
* Store a newly created resource in storage.
*
* @param StoreAdvertRequest $request
* @return Response
* @return void
*/
public function store(StoreAdvertRequest $request)
{
Expand Down Expand Up @@ -95,8 +95,8 @@ public function show(Advert $advert)
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
* @param int $id
* @return void
*/
public function edit($id)
{
Expand Down
8 changes: 4 additions & 4 deletions app/Services/Adverts/AdvertsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
public function showItem($id)
{
$item = $this->advertRepository->find($id);
return ItemDto::make($item);
return $item; //ItemDTO::make($item);
}

public function showAdvertList()
Expand All @@ -42,20 +42,20 @@ public function showAdvertList()
public function showDivisionList()
{
$division =$this->advertRepository->divisionList();
return ItemsDto::make($division);
return ItemsDTO::make($division);
}

public function showTownList()
{
$town = $this->advertRepository->townList();
return ItemsDto::make($town);
return ItemsDTO::make($town);
}

public function page($qty)
{
// return $this->advertCacheRepository->cachingPage($qty);
$pages = $this->advertRepository->paginateList($qty);
return PaginateDto::make($pages);
return PaginateDTO::make($pages);
}


Expand Down
45 changes: 45 additions & 0 deletions app/Services/Adverts/ItemDTO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php


namespace App\Services\Adverts;


class ItemDTO
{

public $items;
public $id;
public $title;
public $price;
public $content;
public $img;
public $created_at;
public $updated_at;
public $userName;
public $user_id;
public $messages;


public static function make($eloquentObject)
{
return new self($eloquentObject);
}

public function __construct($object)
{
$this->id = $object->id;
$this->title = $object->title;
$this->price = $object->price;
$this->content =$object->content;
$this->img = $object->img;
$this->created_at = $object->created_at;
$this->updated_at =$object->updated_at;
$this->userName = $object->user->name;
$this->user_id = $object->user_id;
$this->messages = $object->messages;


}


}
45 changes: 0 additions & 45 deletions app/Services/Adverts/ItemDto.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace App\Services\Adverts;


class ItemsDto
class ItemsDTO
{

public $items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace App\Services\Adverts;


class PaginateDto
class PaginateDTO
{

public $items;
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"laravel/ui": "^2.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^4.0",
"vagrant/calendar": "dev-VMeshavkin/hw13",
"vetalm1/calendar": "dev-master",
"watson/rememberable": "^4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion resources/views/cms/adverts/blocks/item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="row">
<div class="col-md-4 border rounded ">
<img src="{{ URL::asset('img/default.jpg') }}" class="card-img-top" alt="...">
<h5>#{{$advert->id}} - {{$advert->userName}} (id: {{$advert->userId}})</h5>
<h5>#{{$advert->id}} - {{$advert->userName}} (id: {{$advert->user_id}})</h5>
<h3>{{$advert->title}}</h3>
<h3 class="mb-3">Цена: {{$advert->price}} р.</h3>
<p>{{$advert->content}}</p>
Expand Down
3 changes: 3 additions & 0 deletions resources/views/cms/blocks/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<li class="nav-item">
<a class="nav-link" href="/messages">@lang('home.admin-header.messages')</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">@lang('home.admin-header.any')</a>
</li>
Expand Down
3 changes: 3 additions & 0 deletions resources/views/home/blocks/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<li class="nav-item">
<a class="nav-link" href="#">@lang('home.header.services')</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{route('cms')}}">CMS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">@lang('home.header.any')</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
|
*/

Route::get('/cms', 'Cms\CmsController@index')->middleware('auth');
Route::get('/cms', 'Cms\CmsController@index')->middleware('auth')->name('cms');
Route::redirect('/', '/ru/home');

Auth::routes();
Expand Down