如果令牌已在 Flutter 中过期,我正在尝试重定向到登录
尝试获取帖子:
body: new Container(
padding: new EdgeInsets.only(bottom: 8.0),
color: Color(0xff2c3e4e),
child: FutureBuilder<List<Post>>(
future: api.getposts(),
builder: (context, snapshot) {
// doing stuff with response
}
)
)
Run Code Online (Sandbox Code Playgroud)
getposts 并捕获错误:
Future<List<Post>> getposts() async {
url = 'url';
var response = await http.get(url,
headers: {HttpHeaders.authorizationHeader: 'bearer ' + token},
);
//part I can't understand how to get to work, how do I push? This gives error about context not being defined.
if (response.body.toString().contains('Token is Expired')) {
Navigator.push(
context,
MaterialPageRoute(
builder: …Run Code Online (Sandbox Code Playgroud) 是)我有的:
Dismissible(
key: Key(state.threads[index].toString()),
onDismissed: (direction) {
setState(() {
state.threads.removeAt(index);
});
},
);
Run Code Online (Sandbox Code Playgroud)
工作正常。我可以通过向左滑动来消除项目。但是,我想确认该操作,我应该理解和阅读的内容是
confirmDismiss:
但是,作为一个初学者,由于缺乏示例,加上文档字面意义上我无法理解的任何内容。如何实现呢?
尽管阅读了有关命令的文档(您是否可以在 laravel 的命令行上运行 php?),但我根本不明白。
例如,我可以在 linux 的命令行上运行 php 脚本:
php /path/to/my/phpfile.php
Run Code Online (Sandbox Code Playgroud)
我到底怎么能在 Laravel 上做到这一点?假设我有一条通往
Route::get('/runthis', array('as' => 'runthis', 'uses' => 'Controller@runthis'));
Run Code Online (Sandbox Code Playgroud)
如何在 cron 上运行它?
Laravel 版本 4.1
在服务器和域上工作得很好,但我想将其开发到我的本地主机,但我无法登录。我没有收到错误消息,没有任何记录,也没有任何反应,希望我被重定向/login当我尝试登录时返回页面。我已更改session.php, 数据库连接到我的本地主机数据库并将app.php其指向http://localhost(我也尝试将其指向localhost和http://127.0.0.1)。数据库连接正常,登录页面(即首页)加载。文件权限/app/storage正确。
该脚本使用 Sentry2 进行身份验证。我可以尝试什么想法吗?
我对 Laravel 很陌生,不太了解DB::table与AND子句结合使用的方法。
所以我现在有这个查询:
$query = DB::select( DB::raw("SELECT * FROM tablethis WHERE id = '$result' AND type = 'like' ORDER BY 'created_at' ASC"));
Run Code Online (Sandbox Code Playgroud)
它正在工作,但我想使用 Laravel 的查询生成器来生成类似的内容:
$query = DB::table('tablethis')->where('id', '=', $result)->where('type', '=', 'like')->orderBy('created_at', 'desc')
Run Code Online (Sandbox Code Playgroud)
但这似乎where()完全忽略了第二个。那么,基本上我该如何进行这项工作?
我正在运行 echo 服务器和 redis。私人频道完美运行,我为它构建的消息传递也有效。现在我试图让耳语也适用于打字状态,但没有运气。耳语是否需要推动器才能工作?
我在 keyup (jquery) 上的尝试
Echo.private(chat- + userid)
.whisper('typing',{e: 'i am is typing...'});
console.log('key up'); // this one works so the keyup is triggered
Run Code Online (Sandbox Code Playgroud)
那么我当然是在听我正在耳语的频道:
Echo.private(chat- + userid).listenForWhisper('typing', (e) => {
console.log(e + ' this is typing');
});
Run Code Online (Sandbox Code Playgroud)
但我在任何地方都一无所获。(在回显服务器上调试,控制台上没有任何内容)任何有关如何使其工作的帮助将不胜感激。
我想根据 id 运行不同的 ->where() 条件。
举例说明我正在尝试做的事情:
我已将活动表加入到兴趣表中,并根据 ID 我想运行不同的位置条件。
->when('activity.id' <= '214469112', function ($q) {
return $q->where('interests.type', 'regular');
}, function ($q) {
return $q->where('activity.main', 1);
})->get();
Run Code Online (Sandbox Code Playgroud)
然而 ->when() 似乎不尊重 <= => 大于或小于并且总是返回 false,因此 return $q->where('activity.main', 1);总是使用。
我有什么想法可以实现基于大于或小于 Activity.id 的不同 ->where() 条件吗?
我曾经在需要时使用 Laravel 5 在生产中运行 debug true ,方法如下:
'debug' => env('APP_DEBUG', $_SERVER['REMOTE_ADDR'] == 'myipaddress' ? true : false),
Run Code Online (Sandbox Code Playgroud)
然而 Laravel 6 不允许我使用它,当我执行 artisan config:cache 时,artisan 抱怨:
变量 $_server['REMOTE_ADDR'] 未定义且存在。
有人发现还有另一种方法可以用 Laravel 6 来做到这一点吗?