如何以moment.js中的以下格式获取当月的第一天和最后一天以及时间:
2016-09-01 00:00
我可以得到这样的当前日期和时间:
moment().format('YYYY-MM-DD h:m')将以上述格式输出.
但是我需要获取当月第一天和最后一天的日期和时间,无论如何都要这样做?
编辑: 我的问题与此问题不同,因为它询问用户已经拥有的给定月份,而我要求当前月份,同时要求提供另一个未提及的日期的特定格式,即所谓的"重复" ".
在我componentDidMount()进行API调用以获取一些数据时,此调用然后设置我在渲染中使用的状态对象.
componentDidMount() {
const { actions } = this.props;
this.increase = this.increase.bind(this);
// api call from the saga
actions.surveyAnswersRequest();
// set breadcrumb
actions.setBreadcrumb([{ title: 'Score' }]);
actions.setTitle('Score');
this.increase();
}
Run Code Online (Sandbox Code Playgroud)
在我的渲染函数中,我将一些prop值传递给视图文件:
render() {
const { global, gallery, survey_answers, survey, survey_actual_answers } = this.props;
if (global.isFetching) {
return <Loading />;
}
return this.view({ gallery, survey_answers, survey, survey_actual_answers });
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是survey_actual_answers第一次加载页面时没有设置prop,但是当我刷新页面时,prop返回数据正常,脚本的其余部分将运行.这是它第一次为该prop值返回一个空数组.
这就是我传递道具的方式:
Score.propTypes = {
actions: PropTypes.object.isRequired,
global: PropTypes.object.isRequired,
survey: PropTypes.object.isRequired,
survey_answers: PropTypes.object.isRequired,
gallery: PropTypes.object.isRequired,
survey_actual_answers: PropTypes.array.isRequired,
survey_score_system: PropTypes.array.isRequired, …Run Code Online (Sandbox Code Playgroud) 我知道网上有很多这方面的话题,但我发现它们非常复杂.基本上我想将Bootstrap导航菜单转换为WordPress菜单.
假设我有默认的Bootstrap Navbar:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another …Run Code Online (Sandbox Code Playgroud) 如何将主页(/)设置为Laravel 5.3中的登录屏幕?
我有一个路线文件:
Route::get('/', function () {
return view('welcome');
});
Run Code Online (Sandbox Code Playgroud)
我已经使用命令设置了基本的auth脚手架,php artisan make:auth并且也设置了我的数据库表.
但是我很难理解如果用户未经过身份验证,如何将主页设置为始终转到登录屏幕?当然这只是我傻了吧?
我安装了Wampserver 3.0.6 32位,它带有PHP版本5.6.25和7.0.10.
当我从服务器托盘图标从5.6.25切换到7.0.10时,它不会更新我的电脑正在使用的实际php版本.
我可以在命令提示符下运行它来测试它php -v:
PHP 5.6.25 (cli) (built: Aug 18 2016 11:40:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Run Code Online (Sandbox Code Playgroud)
重新启动wamp服务并多次重新打开终端后,它仍然显示相同的内容.
当我在浏览器中访问localhost时,它显示以下内容:
我不知道为什么它仍然显示PHP版本5.6.
有人有主意吗?
在Windows 10 64位操作系统上运行此命令.
我正在使用一个集成Xero记帐的软件包。
他们XeroServiceProvider.php在以下位置有一个名为的文件/vendor/drawmyattention/xerolaravel/Providers/XeroServiceProvider.php。
我需要在应用程序中扩展此服务提供者,但我不喜欢直接编辑此文件的想法。
有没有一种方法可以轻松扩展此服务提供商而无需更新供应商文件?
这是我需要扩展的文件:
namespace DrawMyAttention\XeroLaravel\Providers;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use \App\Invoice;
class XeroServiceProvider extends ServiceProvider
{
private $config = 'xero/config.php';
public function boot()
{
$this->publishes([
__DIR__.'/../config.php' => config_path($this->config),
]);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind('XeroInvoice', function(){
//return new \XeroPHP\Models\Accounting\Invoice();
return new Invoice();
});
}
}
Run Code Online (Sandbox Code Playgroud) 所以我有用户和公司.用户属于一家公司.
我想验证用户注册,以便business_name他们用于注册的字段在companies表中是唯一的,目标是不允许用户创建重复的公司.
这是我的注册功能:
public function register(Request $request)
{
$validator = Validator::make($request->all(), [
'first_name' => 'required',
'last_name' => 'required',
'business_name' => 'required|unique:companies',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6',
]);
if ($validator->fails()) {
return response()->json(['error'=>$validator->messages()], 401);
}
}
Run Code Online (Sandbox Code Playgroud)
我要比较的字段是companies.name检查唯一性.
这可能吗?目前它正试图business_name在companies桌子上寻找.
我有一个User,涉及到的模型Section通过枢轴模式模型UserTrainingSection。我有一个数据透视表,用于存储两个名为section_user.
我有 2 个额外的数据透视表列,称为completed和completed_date。
我遇到的问题是,当我获取数据时,它会返回User模型中的所有列以及其他数据透视列。
class Section extends Model
{
public $table = "sections";
public $fillable = [
'id',
'name',
'description',
'parent',
'position',
'completion_percentage'
];
public function users()
{
return $this->belongsToMany(User::class, 'section_user')->using('App\Models\UserTrainingSection')->withPivot('completed', 'completed_date');
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 API 服务中,我像这样获取我的数据:
Section::with(['users' => function ($q) {
$q->where('users.id', Auth::user()->id);
}])->first();
Run Code Online (Sandbox Code Playgroud)
如何只返回数据透视表列并从用户表中排除列?
目前它返回如下内容:
"sections": [
{
"id": 2,
"name": "Subsection 1 training",
"description": null,
"parent": 1,
"position": 2,
"completion_percentage": null,
"created_at": …Run Code Online (Sandbox Code Playgroud) 我正在使用语义 UI 并创建了一个带有click事件的按钮,该按钮在单击时应打开模态,但没有任何反应。
当我点击链接时没有任何反应,我不知道出了什么问题。
这是按钮:
<a class="item" id="logIn">
<i class="user icon"></i> Log In
</a>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
<script type="text/javascript">
$('#logIn').click(function(){
$('#modaldiv').modal('show');
});
</script>
Run Code Online (Sandbox Code Playgroud)
模态代码:
<div id="modaldiv" class="ui modal">
<i class="close icon"></i>
<div class="header">
Profile Picture
</div>
<div class="content">
<div class="ui medium image">
<img src="/images/avatar/large/chris.jpg">
</div>
<div class="description">
<div class="ui header">We've auto-chosen a profile image for you.</div>
<p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p>
<p>Is it okay to use this photo?</p> …Run Code Online (Sandbox Code Playgroud) Laravel Cashier上的文档含糊不清,并且遗漏了一些非常重要的细节,例如,它$stripeToken是什么以及它来自哪里?
因此,要创建新的订阅,请执行以下操作:
$user->newSubscription('main', 'premium')->create($stripeToken);
Run Code Online (Sandbox Code Playgroud)
这是用户第一次订阅,那么$stripeToken确切的来源是什么?
在文档中说:
接受Stripe信用卡/来源令牌的create方法将开始订阅,并使用客户ID和其他相关账单信息更新数据库。
这是否意味着我必须先在Stripe中手动创建客户对象,然后将客户ID传递为$stripeToken?它提到卡的详细信息,但是我如何通过它们?格式是什么,我期望得到什么?
如果$stripeTokenStripe中的客户ID是,那么Cashier假设我们已经在Stripe中创建了客户,这将是第一次。
谁能对此有所启发?
php ×7
laravel ×5
javascript ×3
laravel-5 ×3
html ×2
billing ×1
css ×1
date ×1
eloquent ×1
jquery ×1
laravel-5.3 ×1
login ×1
modal-dialog ×1
momentjs ×1
orm ×1
php-7 ×1
reactjs ×1
semantic-ui ×1
validation ×1
wamp ×1
wampserver ×1
wordpress ×1