我无法弄清楚如何使用Laravel框架将新列添加到现有数据库表中.
我尝试使用...编辑迁移文件
<?php
public function up()
{
Schema::create('users', function ($table) {
$table->integer("paid");
});
}
Run Code Online (Sandbox Code Playgroud)
在终端,我执行php artisan migrate:install
和migrate
.
如何添加新列?
我在选择框中面临一些问题,我将把所有可用的类别放入其中
在我的控制器中,我正在使用此剪辑:
return View::make("stories.add")
->with("title","Indsend novelle")
->with("categories", Category::all());
Run Code Online (Sandbox Code Playgroud)
在我看来,我试图将所有类别放入选择框中:
{{Form::select("category", $categories)}}
Run Code Online (Sandbox Code Playgroud)
我可以做到这一点,但这不起作用,因为Form :: select必须是一个数组?
@foreach ( $categories as $category )
{{$category->name}}
@endforeach
Run Code Online (Sandbox Code Playgroud)
该怎么办?
我做了这个并且它有效,但它看起来太难看了,不是用户友好的,有什么建议吗?
$test = Category::all(); $myArray = array();
foreach ( $test as $o):
$myArray[] = $o->name;
endforeach;
return View::make("stories.add")
->with("title","Indsend novelle")
->with("categories", $myArray);
Run Code Online (Sandbox Code Playgroud)
的var_dump:
array(2) {
[0]=>
object(Category)#36 (5) {
["attributes"]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(12) "Alderforskel"
["created_at"]=>
string(19) "0000-00-00 00:00:00"
["updated_at"]=>
string(19) "0000-00-00 00:00:00"
}
["original"]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(12) "Alderforskel"
["created_at"]=> …
Run Code Online (Sandbox Code Playgroud) 我如何使用像{{@something}}这样的东西,它会运行一个控制器,检查"某些东西",这样我就可以将它返回到可翻译的文本?
我当前的刀片模板如下所示:
@layout("layouts.default")
@section("inner")
<h1>Velkommen til pornobiksen</h1>
@foreach($videos as $thumb)
{{$thumb}}
@endforeach
@endsection
Run Code Online (Sandbox Code Playgroud)
我的意思是,我怎么能改变"Velkommen til pornobiksen"tekst?我知道我可以做类似的事情
View::make("template")->with("h1_text","Velkommen til pornobiksen");
Run Code Online (Sandbox Code Playgroud)
但是没有一个模块/插件可以让它更容易吗?通过制作{{@ h1_text}},它将从我的数据库或其他东西?
什么是简单的方法来做到这一点?
我一直致力于自己的服装Javascript倒计时,在网站上进行多次倒计时.
但我遇到了问题.日期不正确.
它在谷歌浏览器中完美运行,但在Firefox中它只是说NaN.
有人能告诉我代码有什么问题吗?
function countdown(date, span){
today = new Date();
BigDay = new Date(date);
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
secLeft = Math.floor( 60 - today.getSeconds() );
$("#"+span).html("<ul class='dayTime'><li><small>" + daysLeft + "</small><span>Dage</span></li><li><small>" + hrsLeft +"</small><span>Timer</span></li><li><small>" + minsLeft + "</small><span>Min</span></li><li><small>" + secLeft + "</small><span>Sek</span></li></ul>");
}
Run Code Online (Sandbox Code Playgroud)
我正在运行代码
countdown("2013-05-30 00:00:00", "container");
Run Code Online (Sandbox Code Playgroud)