我正在尝试获取应用程序中的所有用户,以便在选择的表单中选择用户名或ID,但经过长时间的努力,我无法实现这一目标。我检索消息的MessageController是:
public function getMail(){
$message = Message::orderBy('created_at', 'desc')->get();
$pple = User::where('id', '!=', Auth::id())->pluck('name', 'id')->all();
var_dump($pple);
return view('mail', array('user' => $pple))->with('messages', $message, 'users',$pple );
}
我想要呈现用户的观点是:
<div>
<select id="recipient">
<option>{{$pple->name}}</option>
</select>
</div>
我确实尝试过这样做,以帮助我选择一个用户 id 或名称,以便在我的短信系统中使用。如果有人帮我这个,我将不胜感激< / p>
答案 0 :(得分:2)
您应该让您的用户随后获取结果:
$messages = Message::orderBy('created_at', 'desc')->get();
$users = User::where('id', '!=', Auth::id())->pluck('name', 'id');
并返回
return view('mail')->with(compact('messages', 'users'));
然后在您的视图中以这种方式使用
<select name="recipient" id="recipient">
@foreach($users as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@enforeach
</select>
请勿忘记在您的选择中添加name
。
答案 1 :(得分:1)
在您看来,这应该有效
ui <- fluidPage(numericInput(inputId = "one", label="Type number",1, min=1, max=120),
numericInput(inputId = "two", label="Type number",1, min = 1, max=120),
numericInput(inputId = "three", label="Type number",1, min = 1, max=120),
numericInput(inputId = "four", label="Type number",1, min = 1, max=120),
textOutput("sub"), br(),
actionButton("act", "Show"),
br(),
radioButtons(inputId = "RB",label="Choose",
c("English",
"French",
"German",
"Spanish",
"None")),
textOutput("sw"),
textOutput("text")
)
server <- function(input, output){
output$text <- renderText({
RB <- switch(input$RB,
English= "You schould learn German.",
French = "You schould learn Spanish.",
German = "You schould learn English.",
Spanish = "You schould learn Portuguese.",
None ="You schould learn Polish.")
})
variables <- set(wo = fuzzy_partition(varnames = c(notMany2 = 15, enough2 = 25, many2 = 35),FUN = fuzzy_cone, radius = 10),
top = fuzzy_partition(varnames = c(notMany3 = 20, enough3 = 50, many3 = 100),FUN = fuzzy_cone, radius = 25),
c = fuzzy_partition(varnames = c(k4 = 52, k3 = 42, k2 = 32,k1 = 22), sd = 3)
)
rules <- set (fuzzy_rule(wo %is% notMany2 && top %is% notMany3
|| wo %is% notMany2 && top %is% notMany3
|| wo %is% notMany2 && top %is% notMany3
, c %is% k1),
fuzzy_rule( wo %is% notMany2 && top %is% enough3
|| wo %is% notMany2 && top %is% many3,c %is% k2))
system <- fuzzy_system(variables,rules)
fi <- fuzzy_inference(system, list(wo = 20, top= 10))
fuz <- gset_defuzzify(fi, 'centroid')
output$sub <- renderText({fuz})
z <- reactive(if(output$sub=="You schould learn German") (fuz*2))
output$sw <- renderText({z()})
}
shinyApp(ui = ui, server = server)