Merge remote-tracking branch 'origin/v3' into v3-master
This commit is contained in:
commit
38a7bfecf6
3 changed files with 33 additions and 16 deletions
|
@ -12,6 +12,7 @@ use Str;
|
||||||
use View;
|
use View;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
@ -90,12 +91,17 @@ class StatuslabelsController extends Controller
|
||||||
*
|
*
|
||||||
* @return Redirect
|
* @return Redirect
|
||||||
*/
|
*/
|
||||||
public function postCreate()
|
public function postCreate(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
// create a new model instance
|
// create a new model instance
|
||||||
$statuslabel = new Statuslabel();
|
$statuslabel = new Statuslabel();
|
||||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
|
||||||
|
if (!$request->has('statuslabel_types')) {
|
||||||
|
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
||||||
|
|
||||||
// Save the Statuslabel data
|
// Save the Statuslabel data
|
||||||
$statuslabel->name = e(Input::get('name'));
|
$statuslabel->name = e(Input::get('name'));
|
||||||
|
@ -116,11 +122,14 @@ class StatuslabelsController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
// create a new status label instance
|
|
||||||
$statuslabel = new Statuslabel();
|
$statuslabel = new Statuslabel();
|
||||||
|
if (!$request->has('statuslabel_types')) {
|
||||||
|
return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500);
|
||||||
|
}
|
||||||
|
|
||||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
||||||
$statuslabel->name = e(Input::get('name'));
|
$statuslabel->name = e(Input::get('name'));
|
||||||
$statuslabel->user_id = Auth::user()->id;
|
$statuslabel->user_id = Auth::user()->id;
|
||||||
|
@ -135,7 +144,7 @@ class StatuslabelsController extends Controller
|
||||||
// Redirect to the new Statuslabel page
|
// Redirect to the new Statuslabel page
|
||||||
return JsonResponse::create($statuslabel);
|
return JsonResponse::create($statuslabel);
|
||||||
}
|
}
|
||||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($statuslabel->getErrors()->first(), true)], 500);
|
return JsonResponse::create(["error" => $statuslabel->getErrors()->first()], 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +177,7 @@ class StatuslabelsController extends Controller
|
||||||
* @param int $statuslabelId
|
* @param int $statuslabelId
|
||||||
* @return Redirect
|
* @return Redirect
|
||||||
*/
|
*/
|
||||||
public function postEdit($statuslabelId = null)
|
public function postEdit(Request $request, $statuslabelId = null)
|
||||||
{
|
{
|
||||||
// Check if the Statuslabel exists
|
// Check if the Statuslabel exists
|
||||||
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
|
||||||
|
@ -176,6 +185,10 @@ class StatuslabelsController extends Controller
|
||||||
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$request->has('statuslabel_types')) {
|
||||||
|
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update the Statuslabel data
|
// Update the Statuslabel data
|
||||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
|
||||||
|
|
|
@ -16,9 +16,11 @@ class Statuslabel extends Model
|
||||||
|
|
||||||
|
|
||||||
protected $rules = array(
|
protected $rules = array(
|
||||||
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
|
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
|
||||||
//'statuslabel_types' => 'required|in:deployable,pending,archived,undeployable',
|
'notes' => 'string',
|
||||||
'notes' => 'string',
|
'deployable' => 'required',
|
||||||
|
'pending' => 'required',
|
||||||
|
'archived' => 'required',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $fillable = ['name'];
|
protected $fillable = ['name'];
|
||||||
|
@ -47,14 +49,14 @@ class Statuslabel extends Model
|
||||||
public function getStatuslabelType()
|
public function getStatuslabelType()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->pending == 1) {
|
if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||||
return 'pending';
|
return 'pending';
|
||||||
} elseif ($this->archived == 1) {
|
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
|
||||||
return 'archived';
|
return 'archived';
|
||||||
} elseif ($this->deployable == 1) {
|
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
|
||||||
return 'deployable';
|
|
||||||
} else {
|
|
||||||
return 'undeployable';
|
return 'undeployable';
|
||||||
|
} else {
|
||||||
|
return 'deployable';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,12 +76,13 @@ class Statuslabel extends Model
|
||||||
$statustype['pending'] = 0;
|
$statustype['pending'] = 0;
|
||||||
$statustype['deployable'] = 0;
|
$statustype['deployable'] = 0;
|
||||||
$statustype['archived'] = 1;
|
$statustype['archived'] = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$statustype['pending'] = 0;
|
$statustype['pending'] = 0;
|
||||||
$statustype['deployable'] = 0;
|
$statustype['deployable'] = 0;
|
||||||
$statustype['archived'] = 0;
|
$statustype['archived'] = 0;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
return $statustype;
|
return $statustype;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ return array(
|
||||||
),
|
),
|
||||||
"unique" => "The :attribute has already been taken.",
|
"unique" => "The :attribute has already been taken.",
|
||||||
"url" => "The :attribute format is invalid.",
|
"url" => "The :attribute format is invalid.",
|
||||||
|
"statuslabel_type" => "You must select a valid status label type",
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue