假设我在表中有7列,我想只选择其中两列,就像这样
SELECT `name`,`surname` FROM `table` WHERE `id` = '1';
Run Code Online (Sandbox Code Playgroud)
在laravel雄辩的模型中,它可能看起来像这样
Table::where('id', 1)->get();
Run Code Online (Sandbox Code Playgroud)
但我想这个表达式会选择id等于1的所有列,而我只想要两列(name,surname).如何只选择两列?
我正在尝试创建一个报告页面,显示从特定日期到特定日期的报告.这是我目前的代码:
$now = date('Y-m-d');
$reservations = Reservation::where('reservation_from', $now)->get();
Run Code Online (Sandbox Code Playgroud)
这在纯SQL中的作用是什么select * from table where reservation_from = $now.
我在这里有这个查询,但我不知道如何将其转换为雄辩的查询.
SELECT * FROM table WHERE reservation_from BETWEEN '$from' AND '$to
Run Code Online (Sandbox Code Playgroud)
如何将上面的代码转换为雄辩的查询?先感谢您.
我正在尝试使用我的Ubuntu PC上的composer安装laravel安装程序,但是我在安装过程中遇到了这个错误.`您的要求无法解析为可安装的软件包集.
Problem 1
- laravel/installer v1.4.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- laravel/installer v1.4.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- Installation request for laravel/installer ^1.4 -> satisfiable by laravel/installer[v1.4.0, v1.4.1].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- …Run Code Online (Sandbox Code Playgroud) 在Laravel中,我试图在我的控制器中调用$input = Request::all();一个store()方法,但是我收到以下错误:
Illuminate\Http\Request::all()假设$this不兼容的上下文,不应静态调用非静态方法
有任何帮助找出解决这个问题的最佳方法吗?(我跟随拉克拉斯特)
我正在使用Laravel构建一个项目.它在localhost上工作正常,但是当我将它上传到服务器(服务器安装了comodo ssl)时,我收到以下错误:
RuntimeException in EncryptionServiceProvider.php line 29:
No supported encrypter found. The cipher and / or key length are invalid
in EncryptionServiceProvider.php line 29
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 733
at Container->build(object(Closure), array()) in Container.php line 626
at Container->make('encrypter', array()) in Application.php line 674
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 837
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 800
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 771
at Container->build('SahraSalon\Http\Middleware\EncryptCookies', array()) in Container.php line 626
at Container->make('SahraSalon\Http\Middleware\EncryptCookies', array()) in Application.php line 674
at Application->make('SahraSalon\Http\Middleware\EncryptCookies') …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 5.0,从这个版本中删除了Form和Html Helper,我不知道如何在我的头文件中包含外部css和js文件.目前我正在使用此代码.
<link rel="stylesheet" href="/css/bootstrap.min.css"> <!--- css file --->
<script type="text/javascript" src="/js/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过homestead ssh以下方式连接到vagrant :
vagrant@127.0.0.1's password:
Run Code Online (Sandbox Code Playgroud)
但我的公钥密码不起作用.
我的Homestead.yaml看起来像这样:
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
我正在使用"Laravel Homestead版本2.0.14"和"Vagrant 1.7.2".
如何在刀片模板中使用switch?我用的时候:
@switch($login_error)
@case(1)
`E-mail` input is empty!
@break
@case(2)
`Password` input is empty!
@break
@endswitch
Run Code Online (Sandbox Code Playgroud)
结果我将此文本视为明文.我更喜欢在几段代码中使用switch,因为它比我使用if时更干净.
但如果不可能只写它.
我正试图在Laravel中实现一个bittorrent跟踪器.但是,由于下载无法启动,我现在卡住了.有一个同伴似乎是播种,我100%确定它是可连接的.但是,当我在另一台机器上运行第二个客户端时,下载将无法启动.它停留在"连接到同行"(uTorrent).
来自跟踪器,当客户发布通知时,我发送以下响应:
d8:intervali1000e12:min intervali300e5:peers18:???i???XÚJU?6e
Run Code Online (Sandbox Code Playgroud)
在下载客户端中,我有以下数据:
这是我的公告代码:
<?php
namespace App\Http\Controllers\Announce;
use App\Helpers\BencodeHelper;
use App\Models\Peer;
use App\Models\PeerTorrent;
use App\Models\Torrent;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
class AnnounceController extends Controller
{
const __INTERVAL = 1000;
const __TIMEOUT = 120;
const __INTERVAL_MIN = 60;
const __MAX_PPR = 20;
public function announce(Request $request)
{
Log::info($request->fullUrl());
$status = 200;
$content = "";
$passkey = Input::get('passkey');
$peer_id = Input::get('peer_id');
$port = Input::get('port');
$info_hash = Input::get('info_hash');
$downloaded = …Run Code Online (Sandbox Code Playgroud) 在Laravel 5应用程序的根目录下运行以下命令时
php artisan migrate:make create_mytable
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[InvalidArgumentException]
Command "migrate:make" is not defined.
Did you mean one of these?
migrate:reset
migrate:refresh
migrate:status
migrate:rollback
migrate:install
migrate
Run Code Online (Sandbox Code Playgroud)
是否有一种新方法可以在Laravel 5中开始迁移?