从JavaScript按钮单击后,我将使用重定向页面
window.location.href = '//dziennik_zdarzen?id_seo=5';
接下来,我要将其从我的路线传递给控制器,这部分无效
Route::get('dziennik_zdarzen', ['uses'=>'Dziennik_zdarzenController@get_datatable']);
我尝试了很多尝试,例如尝试从url中获取它,但没有成功。所以我试图将其传递给Dziennik_zdarzenController @ get_datatable。我在windows.location.href中将网址更改为类似“ // dziennik_zdarzen / 5”的网址,然后我尝试在路由中传递它。像这样:
Route::get('dziennik_zdarzen/{id_seo}', ['uses'=>'Dziennik_zdarzenController@get_datatable']);
仍然无法正常工作
这是我的控制人
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Yajra\Datatables\Datatables;
use App\Dziennik_zdarzen;
class Dziennik_zdarzenController extends Controller
{
public function get_datatable($id_seo)
{
return $id_seo;
}
}
?>
如果您能指导我我做错了什么,我将不胜感激
答案 0 :(得分:0)
您将id_seo发送为查询参数。您可以使用控制器中的Request对象访问它
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Yajra\Datatables\Datatables;
use App\Dziennik_zdarzen;
class Dziennik_zdarzenController extends Controller
{
public function get_datatable(Request $request)
{
return $request->id_seo;
}
}
?>
如果要将其作为路由参数发送
window.location.href = '//dziennik_zdarzen/5';
答案 1 :(得分:0)
在控制器中:
Aggregation aggregation = newAggregation(
match(
where("domain").is(domain)
.and("contents.contentName").is(templateName)
.and("locale").in(criteria.getLocales())),
project().and(new AggregationExpression() {
@Override
public Document toDocument(AggregationOperationContext aggregationOperationContext) {
DBObject filterExpression = new BasicDBObject();
filterExpression.put("input", "$contents.fields");
filterExpression.put("as", "field");
filterExpression.put("cond",
new BasicDBObject("$eq", Arrays.<Object>asList("$$field.title", "Company Name")));
return new Document("$filter", filterExpression);
}
}).as("field"));
AggregationResults<MyClass> list = mongoOperations.aggregate(aggregation, MyClass.class,
MyClass.class);
路线:
vm.gridOptionsSemester = {
enableRowHeaderSelection: true,
enableFullRowSelection: true,
enableRowSelection: true,
enableSelectAll: true,
multiSelect: true,
saveFocus: false,
saveScroll: true,
saveGroupingExpandedStates: true,
enableFiltering: true,
enableGridMenu: true,
columnDefs: [
{ name: '_id', enableCellEdit: false, visible: false },
{ name: 'name', displayName: 'Semester', enableCellEdit: true, minWidth: 200 },
{ name: 'start', displayName: 'Start Date', enableCellEdit: true, minWidth: 200, type: 'date:\'yyyy-MMM-dd\'', cellFilter: 'date' },
{ name: 'end', displayName: 'End Date', enableCellEdit: true, minWidth: 200, type: 'date:\'yyyy-MMM-dd\'', cellFilter: 'date' },
{
name: 'status.currentSemester', displayName: 'Current Semester', minWidth: 150, editableCellTemplate: 'ui-grid/dropdownEditor', width: '20%',
editDropdownValueLabel: 'current', editDropdownOptionsArray: [
{ id: true, current: true },
{ id: false, current: false }
]
},
{
name: 'status.viewable', displayName: 'Viewable', minWidth: 100, editableCellTemplate: 'ui-grid/dropdownEditor', width: '20%',
editDropdownValueLabel: 'viewable', editDropdownOptionsArray: [
{ id: true, viewable: true },
{ id: false, viewable: false }
]
},
{
name: 'status.openForProposal', displayName: 'Proposable', minWidth: 100, editableCellTemplate: 'ui-grid/dropdownEditor', width: '20%',
editDropdownValueLabel: 'openForProposal', editDropdownOptionsArray: [
{ id: true, openForProposal: true },
{ id: false, openForProposal: false }
]
},
{
name: 'status.openForApply', displayName: 'Applicable', minWidth: 100, editableCellTemplate: 'ui-grid/dropdownEditor', width: '20%',
editDropdownValueLabel: 'openForApply', editDropdownOptionsArray: [
{ id: true, openForApply: true },
{ id: false, openForApply: false }
]
},
],
onRegisterApi: function (gridApi) {
//Used for Editing Semesters rmart080
var location = 0;
vm.gridApi = gridApi;
//vm.gridApi.grid.registerRowsProcessor( vm.semesterFilter, 8 );
gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDef, newValue, oldValue) {
console.log(rowEntity._id)
for (; location < vm.gridOptionsSemester.data.length; location++) {
if (vm.gridOptionsSemester.data[location]._id === rowEntity._id) {
break;
}
}
var semUpdate = vm.gridOptionsSemester.data[location];
semUpdate.colDef = newValue;
console.log(semUpdate._id + ' ' + semUpdate.colDef + ' ' + vm.gridOptionsSemester.data[location].endDate);
ProjectService.editTerm(semUpdate, semUpdate._id).then(function (success) {
console.log("Successfully Edited Semester");
semesterchange_msg();
resetSemSettings();
});
});
},
};
不需要use语句,依赖项注入或route参数。