UpdateEntryCommandHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Entries\Handler;
4
5
use DB;
6
use Carbon\Carbon;
7
use Hechoenlaravel\JarvisFoundation\Entries\Events\EntryWasUpdated;
8
9
/**
10
 * Class UpdateEntryCommandHandler
11
 * @package Hechoenlaravel\JarvisFoundation\Entries\Handler
12
 */
13
class UpdateEntryCommandHandler
14
{
15
    /**
16
     * @param $command
17
     * @return array
18
     */
19
    public function handle($command)
20
    {
21
        $command->input['updated_at'] = Carbon::now();
22
        DB::table($command->entity->getTableName())->where('id', $command->entry_id)->update($command->input);
23
        event(new EntryWasUpdated($command->entity, $command->entry_id, $command->input));
24
        return [
25
            'entry_id' => $command->entry_id,
26
            'input' => $command->input
27
        ];
28
    }
29
}
30