1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Gitamin. |
5
|
|
|
* |
6
|
|
|
* Copyright (C) 2015-2016 The Gitamin Team |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gitamin\Http\Controllers\Projects; |
13
|
|
|
|
14
|
|
|
use Gitamin\Commands\Comment\AddCommentCommand; |
15
|
|
|
use Gitamin\Http\Controllers\Controller; |
16
|
|
|
use Gitamin\Models\Comment; |
17
|
|
|
use Gitamin\Models\Project; |
18
|
|
|
use GrahamCampbell\Binput\Facades\Binput; |
19
|
|
|
use Illuminate\Support\Facades\Auth; |
20
|
|
|
use Illuminate\Support\Facades\Redirect; |
21
|
|
|
use Illuminate\Support\Facades\View; |
22
|
|
|
|
23
|
|
|
class CommentsController extends Controller |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Show the form for creating a new resource. |
27
|
|
|
* |
28
|
|
|
* @return \Illuminate\Http\Response |
29
|
|
|
*/ |
30
|
|
|
public function createAction($owner_path, $project_path) |
31
|
|
|
{ |
32
|
|
|
$project = Project::findByPath($owner_path, $project_path); |
33
|
|
|
$commentData = Binput::get('comment'); |
34
|
|
|
|
35
|
|
|
try { |
36
|
|
|
$commentData['author_id'] = Auth::user()->id; |
37
|
|
|
$commentData['project_id'] = $project->id; |
|
|
|
|
38
|
|
|
$comment = $this->dispatchFromArray(AddCommentCommand::class, $commentData); |
|
|
|
|
39
|
|
|
} catch (ValidationException $e) { |
|
|
|
|
40
|
|
|
return Redirect::route('projects.issue_show', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $commentData['target_id']]) |
41
|
|
|
->withInput(Binput::all()) |
42
|
|
|
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.issues.new.failure'))) |
43
|
|
|
->withErrors($e->getMessageBag()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return Redirect::route('projects.issue_show', ['owner' => $owner_path, 'project' => $project_path, 'issue' => $commentData['target_id']]) |
47
|
|
|
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.issues.new.success'))); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.