如何命名我的Route::resource
以便稍后在Laravel 5.5中调用它?
这很有效
Route::get('newclientTAB', 'NewClientControllerTAB@index')->name('newclientTAB');
这不是
Route::resource('articles','ArticleController')->name('articles');
答案 0 :(得分:5)
如果您使用:
val df = Seq(
(8, "PA1", 1.0, 1.18, "pass", "testlog18"),
(7, "PA1", 1.0, 1.17, "fail", "testlog17"),
(6, "PA1", 1.0, 1.16, "pass", "testlog16"),
(5, "PA1", 1.0, 1.15, "fail", "testlog15"),
(4, "PA1", 2.0, 1.14, "fail", "testlog14"),
(3, "PA1", 1.0, 1.13, "pass", "testlog13"),
(2, "PA1", 2.0, 1.12, "pass", "testlog12"),
(1, "PA1", 1.0, 1.11, "fail", "testlog11")
).toDF("sernum", "product", "state", "testDateTime", "testResult", "msg")
df
.withColumn("group", sum(when($"testResult" === "pass", 1)).over(Window.partitionBy($"product", $"state").orderBy($"testDateTime")))
.withColumn("passMsg", when($"group".isNotNull,first($"msg").over(Window.partitionBy($"product", $"state", $"group").orderBy($"testDateTime"))))
.drop($"group")
.where($"testResult"==="fail")
.orderBy($"product", $"state", $"testDateTime")
.show()
+------+-------+-----+------------+----------+---------+---------+
|sernum|product|state|testDateTime|testResult| msg| passMsg|
+------+-------+-----+------------+----------+---------+---------+
| 7| PA1| 1.0| 1.17| fail|testlog17|testlog16|
| 5| PA1| 1.0| 1.15| fail|testlog15|testlog13|
| 4| PA1| 2.0| 1.14| fail|testlog14|testlog12|
| 1| PA1| 1.0| 1.11| fail|testlog11| null|
+------+-------+-----+------------+----------+---------+---------+
Laravel将自动为您的路线设置名称。
你可以运行:
Route::resource('articles','ArticleController')
看到他们。
遗嘱名称为:
但是,如果要使用自定义名称前缀,可以将其设置为:
php artisan route:list
然后您的路线将会显示名称Route::resource('articles','ArticleController', ['names' => 'xyz'])
,xyz.index
等等
如果您想要更进一步,您还可以设置个别名称,例如:
xyz.store
因此您只能为某些路线设置名称,因此您将获得Route::resource('articles','ArticleController', ['names' => ['create' => 'foo','update' => 'bar']])
,foo
和bar
,articles.index
等等