CommenterComposer.php
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace FootyRoom\Http\ViewComposers;
use Illuminate\View\View;
class CommenterComposer
{
/**
* Default options.
*
* @var array
*/
protected $options = [
'hasHeader' => true,
'action' => '/comments',
'allowImages' => false,
'charsLimit' => 800,
];
/**
* Compose the view.
*
* @param \Illuminate\View\View $view
* @param int $postId
* @param object $user
* @param array $options Options for the commenter.
*
* - hasHeader
* - action
* - allowImages
* - allowVideos
* - charsLimit
*
* @return \Illuminate\View\View
*/
public function compose(View $view, $postId, $user, $options = [])
{
if (!isset($options['allowImages']) && $user) {
$options['allowImages'] = true;
}
$options = (object) array_merge($this->options, $options);
$options->postId = $postId;
$view->with('commenter', $options);
return $view;
}
}