我在商品详情中搜索用户名的查询如下:
$data = Store::join('users AS b', 'b.id', '=', 'stores.user_id')
->where('b.name', 'like', '%hazard%')
->paginate();
Run Code Online (Sandbox Code Playgroud)
有用。但我使用 join 来做到这一点。
我怎样才能使用belongto做到这一点?
我的商店模型是这样的:
class Store extends Model
{
protected $fillable = ['name', 'user_id', ...];
public function user()
{
return $this->belongsTo(User::class,'user_id', 'id');
}
...
}
Run Code Online (Sandbox Code Playgroud) 我使用 Laravel 5.3
我的 Laravel 口才是这样的:
$query = User::where('year', '=', (string)$object->year)
->where(\DB::raw('substr(code, 1, 3)'), '=', 511)
->get();
Run Code Online (Sandbox Code Playgroud)
我这样尝试,但它不起作用
我该如何解决?
它的描述如下:
persistence(39) == 3 // because 3*9 = 27, 2*7 = 14, 1*4=4
// and 4 has only one digit
persistence(999) == 4 // because 9*9*9 = 729, 7*2*9 = 126,
// 1*2*6 = 12, and finally 1*2 = 2
persistence(4) == 0 // because 4 is already a one-digit number
Run Code Online (Sandbox Code Playgroud)
我只能这样做:
$array = str_split(39);
foreach ($array as $key => $value) {
echo $array[$key]*$array[$key+1];
}
Run Code Online (Sandbox Code Playgroud)
接下来我很困惑
解决我的问题的任何解决方案?
我的看法是这样的:
<div class="col-md-8">
...
<star :value="{{ $data['rating'] }}"></star>
...
</div>
Run Code Online (Sandbox Code Playgroud)
我的明星部分是这样的:
<template>
<span class="rating" :class='{"disable-all-rating": !!value}'>
<template v-for="item in items">
<label class="radio-inline input-star" :class="{'is-selected': ((starValue>= item.value) && starValue!= null)}">
<input type="radio" class="input-rating" v-model="starValue" @click="rate(item.value)">
</label>
</template>
</span>
</template>
<script>
export default{
props: {
'value': null
},
computed: {
starValue () {
return this.temp_value
}
},
data(){
return{
items: [
{value: 5},
{value: 4},
{value: 3},
{value: 2},
{value: 1}
],
temp_value: null,
}
},
methods:{
rate: function (star) {
this.$http.post(window.BaseUrl …
Run Code Online (Sandbox Code Playgroud) 我的vue组件是这样的:
<template>
<div>
<div class="row">
<div class="col-sm-3">
<div class="form-group">
<label for="status" class="sr-only">Status</label>
<select class="form-control" v-model="selected" @change="filterByStatus()">
<option value="">All Status</option>
<option v-for="status in orderStatus" v-bind:value="status.id">{{ status.name }}</option>
</select>
</div>
</div>
</div>
...
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
export default {
...
data() {
return { selected: '' }
},
methods: {
filterByStatus: function() {
this.$store.state.status = this.selected
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我的模块订购vuex是这样的:
import { set } from 'vue'
import order from '../../api/order'
import * as types …
Run Code Online (Sandbox Code Playgroud) 演示和我的代码是这样的:
https://jsfiddle.net/oscar11/uqoo0qbs/1/
我加 :
"legend": {},
Run Code Online (Sandbox Code Playgroud)
用于查看标题的脚本
我的图片是这样的:
看到我给出红色的照片.我想删除它,但我很困惑.
解决我的问题的任何解决方案?
我从这里得到参考:https : //github.com/barryvdh/laravel-dompdf
我的控制器代码是这样的:
public function listdata()
{
$pdf=PDF::loadView('pdf.test_pdf');
return $pdf->stream('test_pdf.pdf');
}
Run Code Online (Sandbox Code Playgroud)
我尝试\config\dompdf
像这样设置风景:
'show_warnings' => false, // Throw an Exception on warnings from dompdf
'orientation' => 'landscape',
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用。结果仍然是肖像
有没有人可以帮助我?
我通过像这样编辑 app\Console\Kernel.php 在 laravel 5.3 上创建了一个 cron 作业:
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use DB;
class Kernel extends ConsoleKernel
{
protected $commands = [
//
];
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$id = 1;
DB::table('orders')
->where('id', $id)
->update(['status ' => 2, 'canceled_at' => date("Y-m-d H:i:s")]);
})->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
}
Run Code Online (Sandbox Code Playgroud)
我试图检查数据库中的表,但它没有更新
如何测试我的 cron 工作?
我的组件是这样的:
<template>
...
<input type="text" class="form-control" v-model="rawFilter" placeholder="Search" @keyup="getPlayers">
...
</template>
<script>
import _ from 'lodash'
...
export default {
...
data() {
return{
msg:'hello vue',
rawFilter:'',
loading:false
}
},
...
methods: {
getPlayers: _.debounce(function(e) {
const text = e.target.value.trim()
this.$store.dispatch('getPlayers', {
q: text
})
},1000),
...
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
当我搜索时,在显示数据之前,我想添加一个加载图标
我怎么能在vue.js 2中做到这一点?
我从这里得到:https : //github.com/barryvdh/laravel-dompdf
我的控制器是这样的:
public function listdata()
{
$pdf=PDF::loadView('print_tests.test_pdf');
$pdf->setPaper('L', 'landscape');
return $pdf->stream('test_pdf.pdf');
}
Run Code Online (Sandbox Code Playgroud)
我的观点是这样的:
<script type="text/php">
if ( isset($pdf) ) {
$x = 72;
$y = 18;
$text = "{PAGE_NUM} of {PAGE_COUNT}";
$font = $fontMetrics->get_font("Arial", "bold");
$size = 6;
$color = array(0,0,0);
$word_space = 0.0; // default
$char_space = 0.0; // default
$angle = 0.0; // default
$pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
}
</script>
Run Code Online (Sandbox Code Playgroud)
我用这个:
"barryvdh/laravel-dompdf": "^0.7.0",
执行时,字体不是Arial,页面不显示。
我该如何解决?