forked from mikelbring/tinyissue
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: generic add issue form in dashboard
- Loading branch information
Showing
28 changed files
with
396 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Tinyissue package. | ||
* | ||
* (c) Mohamed Alsharaf <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tinyissue\Form; | ||
|
||
use Tinyissue\Model; | ||
|
||
/** | ||
* GlobalIssue is a class to defines fields & rules for adding an issue form | ||
* | ||
* @author Mohamed Alsharaf <[email protected]> | ||
*/ | ||
class GlobalIssue extends Issue | ||
{ | ||
/** | ||
* List of projects | ||
* | ||
* @var array | ||
*/ | ||
protected $projects = []; | ||
|
||
/** | ||
* Returns list of logged in user projects | ||
* | ||
* @return array | ||
*/ | ||
protected function getProjects() | ||
{ | ||
if (!$this->projects) { | ||
$this->projects = \Auth::user()->projects()->get()->lists('name', 'id'); | ||
} | ||
|
||
return $this->projects; | ||
} | ||
|
||
/** | ||
* @param array $params | ||
* | ||
* @return void | ||
*/ | ||
public function setup(array $params) | ||
{ | ||
$this->project = new Model\Project(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function actions() | ||
{ | ||
return [ | ||
'submit' => 'create_issue', | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function fields() | ||
{ | ||
$fields = $this->fieldTitle(); | ||
|
||
$fields['project'] = [ | ||
'type' => 'select', | ||
'label' => 'project', | ||
'options' => $this->getProjects()->all(), | ||
]; | ||
|
||
$fields += $this->fieldBody(); | ||
$fields += $this->fieldTags(); | ||
|
||
// Only on creating new issue | ||
$fields += $this->fieldUpload(); | ||
|
||
return $fields; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
$rules = parent::rules(); | ||
$rules['project'] = 'required|in:' . $this->getProjects()->keys()->implode(','); | ||
|
||
return $rules; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRedirectUrl() | ||
{ | ||
return 'projects/new-issue'; | ||
} | ||
} |
Oops, something went wrong.