我刚刚在一个实时服务器上启动了一个Laravel 5.3项目,除了一个之外,一切顺利.
但我的问题是,我的网站运行在所有3个不同的URL上.
我的服务器是Ubuntu 16.4.
website.com
website.com/public/index.php
website.com/任何单词/index.php
我.htaccess是:(此文件位于根文件夹中)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^(.*)$ public/index.php$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
但我只是想看看我的网站只有website.comURL.
我用这个命令升级PHP 7.0到7.1:
1. sudo add-apt-repository ppa:ondrej/php
2. sudo apt-get update
3. sudo apt-get install php7.1
Run Code Online (Sandbox Code Playgroud)
并从以下命令运行此命令laravel.com:
composer create-project --prefer-dist laravel/laravel blog
运行此代码后,出现以下错误:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework v5.6.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework 5.6.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- Installation request for …Run Code Online (Sandbox Code Playgroud) 我需要在Python中使用带有请求的json发送数据.
Python版本: 2.7.6
OS: Ubuntu 16.04
例如:
import json
import requests
f = requests.Session()
data = {
"from_date": "{}".format(from_date),
"to_date": "{}".format(to_date),
"Action": "Search"
}
get_data = f.post(URL, json=data, timeout=30, verify=False)
Run Code Online (Sandbox Code Playgroud)
但运行此代码后,显示此错误:
get_data = f.post(URL, json=data, timeout=30, verify=False)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 497, in post
return self.request('POST', url, data=data, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
Run Code Online (Sandbox Code Playgroud)
如何发出这个问题?
我需要检查某些路由的域。然后检查后,我需要将域名重定向https://two.com到laravel 中的https://one.comwith middleware。
例如:
路线:
Route::get('/', ['as' => 'index', 'uses' => 'IndexController@index']);
Route::get('termsAndCondition', ['as' => 'termsAndCondition', 'uses' => 'IndexController@termsAndCondition']);
Route::get('aboutUs', ['as' => 'aboutUs', 'uses' => 'IndexController@aboutUs']);
Route::get('privacy', ['as' => 'privacy', 'uses' => 'IndexController@privacy']);
Run Code Online (Sandbox Code Playgroud)
我需要检查aboutUs和privacy域名。
如果域名是https://two.com/aboutUs或https://two.com/privacy重定向到https://one.com/aboutUs或https://one.com/privacy.
我需要检查中间件。
谢谢。
groupBy('date')我需要在使用 Eloquent、create和sortBy('price')in获取 sql 查询collect后Laravel 5.3。
在IndexController:
$flights = Flights::GetFlights($fromCity, $toCity, $fromDate);
$collection = collect($flights);
$sortFlight = $collection->groupBy('date')->sortBy('price');
Run Code Online (Sandbox Code Playgroud)
在Model:
public function scopeGetFlights($query, $fromCity, $toCity, $fromDate)
{
// Between dates
$beforeDate = date('Y-m-d', strtotime($fromDate . '- 10 days'));
$afterDate = date('Y-m-d', strtotime($fromDate . '+ 10 days'));
$join = $query
-> join('airlines', 'airlines.pana', 'flights.airline')
-> where('flights.from_city', $fromCity)
-> where('flights.to_city', $toCity)
-> whereBetween('flights.date', [$beforeDate, $afterDate])
-> get([
'flights.*',
'airlines.pana as pana',
'airlines.name as …Run Code Online (Sandbox Code Playgroud) I create migration in laravel 5.6.
I need add user information if the user was logged in my website else add 0 in column.
My code is:
$table->integer('user_id')->default(0);
$table->foreign('user_id')->references('id')->on('users');
Run Code Online (Sandbox Code Playgroud)
But aftre run migrate show this error:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
Run Code Online (Sandbox Code Playgroud)
I need add default 0 or null in column or add user_id in column if the user was logged in my website.
How to issue this problem?
我在laravel 5.6中创建带有迁移的表。
我需要通过迁移创建唯一索引。
我的代码是:
$table->index([
'system',
'code',
'city',
'seat',
'type'
], 'PrimaryPayment');
Run Code Online (Sandbox Code Playgroud)
但是跑完之后migrate。在phpmyadmin -> table -> table_name -> indexes表演unique: No
如何创建唯一索引?
我的框架是Laravel 5.2,如何{faq}在刀片中使用?
路线是:
Route::get('help/{faq?}', ['as' => 'help', 'uses' => 'Site\Help\IndexController@index']);
Run Code Online (Sandbox Code Playgroud)
网址是:
http://localhost:8000/help/general
Run Code Online (Sandbox Code Playgroud)
我进入{faq}了网址.
在PHP中,如果这个网址:http://localhost:8000/help?faq=general使用$_GET['faq']但不能$_GET在laravel的balde中工作.
请指导我.
我曾经使用 laravel 5.5 及早于https://github.com/Hesto/multi-auth。
但此存储库不会针对 laravel 7.0 进行更新
如何在 Laravel 7.0 中创建多重身份验证?
我需要在谷歌地图上的两点之间画一条曲线。
如何使用 jQuery 进行绘图?
此代码适用于一点。如何更改 2 点并在 Google 地图中的两点之间绘制一条曲线?
我的代码是:
if ($('#map-canvas-airport').length) {
var map,
service;
jQuery(function($) {
$(document).ready(function() {
var lat = $('#airport-map').data('google-lat');
var lng = $('#airport-map').data('google-lng');
var latlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: 13,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
map = new google.maps.Map(document.getElementById("map-canvas-airport"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
marker.setMap(map);
$('a[href="#google-map-tab"]').on('shown.bs.tab', function(e) {
google.maps.event.trigger(map, 'resize');
map.setCenter(latlng);
});
});
});
}
Run Code Online (Sandbox Code Playgroud)
在 HTML 中:
<div class="tab-pane fade" id="airport-map" …Run Code Online (Sandbox Code Playgroud) 我听说Laravel 5.4将于明天公布.
如何安装(Laravel 5.4)Beta版?
你知道新功能吗?
laravel ×9
laravel-5 ×4
laravel-5.3 ×2
migration ×2
.htaccess ×1
apache ×1
google-maps ×1
install ×1
javascript ×1
jquery ×1
json ×1
laravel-5.2 ×1
laravel-5.4 ×1
laravel-7 ×1
linux ×1
php ×1
python ×1
ubuntu-16.04 ×1