本文整理汇总了PHP中app\helpers\Helper::validator方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::validator方法的具体用法?PHP Helper::validator怎么用?PHP Helper::validator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\helpers\Helper
的用法示例。
在下文中一共展示了Helper::validator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the department to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Get selected department
$department = Department::find($id);
// Only continue if one was found
if ($department == null) {
return redirect()->route('dashboard.settings.departments.index')->with('message', 'Error: Department not found');
}
// Get request inputs
$txtDepartmentName = $request->input('txtDepartmentName');
$data = array('txtDepartmentName' => $txtDepartmentName);
$rules = array('txtDepartmentName' => 'required|min:1|max:40|unique:department,name,' . $id);
// Validate input
$reponse = Helper::validator($data, $rules, 'dashboard.settings.departments.index');
if (isset($reponse)) {
return $reponse;
}
// Update department
$department->name = $txtDepartmentName;
$department->save();
return redirect()->route('dashboard.settings.departments.index')->with('message', 'Department updated successfully');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the template to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Load selected templates
$template = Template::find($id);
if ($template == null) {
return redirect()->route('dashboard.settings.templates.index')->with('message', 'Error: Template not found');
}
// Get request inputs
$txtTemplateName = $request->input('txtTemplateName');
$txtTemplateClass = $request->input('txtTemplateClass');
$numTemplateDuration = $request->input('numTemplateDuration');
$data = array('txtTemplateName' => $txtTemplateName, 'txtTemplateClass' => $txtTemplateClass, 'numTemplateDuration' => $numTemplateDuration);
$rules = array('txtTemplateName' => 'required|max:60|unique:template,name,' . $id, 'txtTemplateClass' => 'required|max:50|unique:template,class_name,' . $id, 'numTemplateDuration' => 'required|integer|min:1');
// Validate
$reponse = Helper::validator($data, $rules, 'dashboard.settings.templates.index');
if (isset($reponse)) {
return $reponse;
}
// Update
$template->name = $txtTemplateName;
$template->class_name = $txtTemplateClass;
$template->duration = $numTemplateDuration;
// Upload image 1
$imageInput = Input::file('filTemplateThumbnail');
if ($imageInput != null) {
$imagePath = Images::processImage($imageInput, 'template_thumbmails');
// If we have a valid image then set the path in the database
if ($imagePath != null) {
$template->thumbnail = $imagePath;
}
}
// Update!
$template->save();
return redirect()->route('dashboard.settings.templates.index')->with('message', 'Templated updated successfully');
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the screen to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Load selected screen
$screen = Screen::find($id);
if ($screen == null) {
return redirect()->route('dashboard.settings.screens.index')->with('message', 'Error: Screen not found');
}
// Get request input
$locationID = $request->input('drpLocations');
//$playlistID = $request->input('drpPlaylists');
$data = array('drpLocations' => $locationID);
$rules = array('drpLocations' => 'required|exists:location,id');
// Validate
$reponse = Helper::validator($data, $rules, 'dashboard.settings.screens.index');
if (isset($reponse)) {
return $reponse;
}
// Update screen
$screen->location_id = $locationID;
//$screen->playlist_id = empty($playlistID)? 1 : $playlistID;
$screen->save();
return redirect()->route('dashboard.settings.screens.index')->with('message', 'Screen updated successfully');
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the user to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Get selected user
$user = User::find($id);
if ($user == null) {
return redirect()->route('dashboard.settings.users.index')->with('message', 'Error: User not found');
}
// Get all request inputs
$data = $request->all();
$rules = array('username' => 'min:1|max:40|unique:user,username,' . $id, 'password' => 'confirmed|min:6|max:60');
// Validate
$reponse = Helper::validator($data, $rules, 'dashboard.settings.users.index');
if (isset($reponse)) {
return $reponse;
}
// Update
$user->username = $data['username'];
if (isset($data['password'])) {
$user->password = bcrypt($data['password']);
}
$user->save();
return redirect()->route('dashboard.settings.users.index')->with('message', 'User created successfully');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the location to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Get selected location
$location = Location::find($id);
if ($location == null) {
return redirect()->route('dashboard.settings.locations.index')->with('message', 'Error: Location not found');
}
// Request input
$txtLocationName = $request->input('txtLocationName');
$departmentID = $request->input('drpDepartments');
$playlistID = $request->input('drpPlaylists');
$data = array('txtLocationName' => $txtLocationName, 'drpDepartments' => $departmentID, 'drpPlaylists' => $playlistID);
$rules = array('txtLocationName' => 'required|max:40|unique:location,name,' . $id, 'drpDepartments' => 'required|exists:department,id', 'drpPlaylists' => 'required|exists:playlist,id');
// Validate input
$reponse = Helper::validator($data, $rules, 'dashboard.settings.locations.index');
if (isset($reponse)) {
return $reponse;
}
// Update location
$location->name = $txtLocationName;
$location->department_id = $departmentID;
$location->playlist_id = $playlistID;
$location->save();
return redirect()->route('dashboard.settings.locations.index')->with('message', 'Location updated successfully');
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the background to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Get selected background
$background = Background::find($id);
if ($background == null) {
return redirect()->route('dashboard.settings.backgrounds.index')->with('message', 'Error: Background not found');
}
$btnRemoveColour = $request->input('btnRemoveColour');
// Check if the user wants to just remove the background colour.
if (isset($btnRemoveColour)) {
$background->hex_colour = "";
$background->save();
return redirect()->route('dashboard.settings.backgrounds.index')->with('message', 'Background colour removed!');
}
// Get request inputs
$txtBackgroundName = $request->input('txtBackgroundName');
$hexBackgroundColor = $request->input('hexBackgroundColor');
// Validation
$data = array('txtBackgroundName' => $txtBackgroundName);
$rules = array('txtBackgroundName' => 'required|min:1|max:40|unique:background,name,' . $id);
// Validate inputs
$reponse = Helper::validator($data, $rules, 'dashboard.settings.backgrounds.index');
if (isset($reponse)) {
return $reponse;
}
$background->name = $txtBackgroundName;
// Upload image 1
$imageInput = Input::file('filBackgroundImage');
if ($imageInput != null) {
$imagePath = Media::processMedia($imageInput, 'advert_backgrounds/');
// If we have a valid image then set the path in the database
if ($imagePath != null) {
$background->image_path = $imagePath;
}
}
$background->hex_colour = $hexBackgroundColor;
$background->save();
// Update
return redirect()->route('dashboard.settings.backgrounds.index')->with('message', 'Background updated successfully');
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the advert to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Get selected advert
$advert = Advert::find($id);
if ($advert == null) {
return redirect()->route('dashboard.advert.index')->with('message', 'Error: Could not find advert to update');
}
// Get request inputs
$txtAdvertName = $request->input('txtAdvertName');
$departmentID = $request->input('drpDepartments');
$backgroundID = $request->input('drpBackgrounds');
// Validate input
$rules = array('txtAdvertName' => 'required|max:40', 'drpDepartments' => 'required|exists:department,id', 'drpBackgrounds' => 'required|exists:background,id');
$data = array('txtAdvertName' => $txtAdvertName, 'drpDepartments' => $departmentID, 'drpBackgrounds' => $backgroundID);
$reponse = Helper::validator($data, $rules, 'dashboard.advert.index');
if (isset($reponse)) {
return $reponse;
}
// Update selected advert object
$advert->name = $txtAdvertName;
$advert->department_id = $departmentID;
$advert->background_id = $backgroundID;
$advert->save();
// Update
return redirect()->route('dashboard.advert.index')->with('message', 'Advert: ' . $advert->name . ' updated successfully');
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $adID ID of the advert the page belongs to
* @param int $id ID of the page to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $adID, $id)
{
$txtHeading = $request->input('txtPageName');
$txtContent = $request->input('txtPageContent');
$templateID = $request->input('txtTemplate');
$txtTransition = $request->input('drpTransitions');
$txtDirection = $request->input('drpTransitionDirection');
$data = array('txtPageName' => $txtHeading, 'txtContent' => $txtContent, 'txtTemplate' => $templateID);
$rules = array('txtPageName' => 'max:255', 'txtContent' => 'max:255', 'txtTemplate' => 'required|exists:template,id');
// Validate input
$response = Helper::validator($data, $rules, 'dashboard.advert.edit', [$adID]);
if (isset($response)) {
return $response;
}
$page = Page::find($id);
$page->template_id = $templateID;
$page->transition = $txtTransition . $txtDirection;
$page->save();
$pageData = $page->PageData;
$pageData->heading = $txtHeading;
$pageData->content = $txtContent;
// Upload image 1
$imageInput = Input::file('filPageImage');
if ($imageInput != null) {
$imagePath = Media::processMedia($imageInput, 'advert_images/');
// If we have a valid image then set the path in the database
if ($imagePath != null) {
$pageData->image_path = $imagePath;
}
}
$videoInput = Input::file('filPageVideo');
if ($videoInput != null) {
$videoPath = Media::processMedia($videoInput, 'advert_videos/');
// If we have a valid image then set the path in the database
if ($videoPath != null) {
$pageData->video_path = $videoPath;
}
}
$pageData->save();
$btnSaveClose = $request->input('btnSaveClose');
$btnNext = $request->input('btnNext');
if (isset($btnSaveClose)) {
return redirect()->route('dashboard.advert.edit', [$adID])->with('message', 'Page saved!');
}
if (isset($btnNext)) {
return redirect()->route('dashboard.advert.{adID}.page.create', [$adID])->with('message', 'Page saved! And new page created!');
}
return redirect()->route('dashboard.advert.{adID}.page.show', [$adID, $page->id])->with('message', 'Page created successfully');
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id ID of the playlist to update
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$playlist = Playlist::find($id);
if ($playlist == null) {
return redirect()->route('dashboard.playlist.index')->with('message', 'Error: Playlist not found');
}
$txtPlaylistName = $request->input('txtPlaylistName');
$departmentID = $request->input('drpDepartments');
$data = array('txtPlaylistName' => $txtPlaylistName, 'drpDepartments' => $departmentID);
$rules = array('txtPlaylistName' => 'required|min:1|max:60|unique:playlist,name,' . $id, 'drpDepartments' => 'required|exists:department,id');
// Validate
$reponse = Helper::validator($data, $rules, 'dashboard.playlist.index');
if (isset($reponse)) {
return $reponse;
}
$playlist->name = $txtPlaylistName;
$playlist->department_id = $departmentID;
$playlist->save();
return redirect()->route('dashboard.playlist.index')->with('message', 'Playlist updated successfully');
}