小编myS*_*Sun的帖子

如何为Laravel发布和定制.htaccess?

我刚刚在一个实时服务器上启动了一个Laravel 5.3项目,除了一个之外,一切顺利.

但我的问题是,我的网站运行在所有3个不同的URL上.

我的服务器是Ubuntu 16.4.

  1. website.com

  2. website.com/public/index.php

  3. 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 apache .htaccess laravel laravel-5.3

7
推荐指数
1
解决办法
5552
查看次数

如何在ubuntu 16.04中安装laravel 5.6?

我用这个命令升级PHP 7.07.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)

linux install laravel laravel-5 ubuntu-16.04

5
推荐指数
1
解决办法
4609
查看次数

request()得到了一个意外的关键字参数'json'

我需要在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)

如何发出这个问题?

python json python-requests

4
推荐指数
1
解决办法
1万
查看次数

如何检查 Laravel 中的某些路由的域?

我需要检查某些路由的域。然后检查后,我需要将域名重定向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)

我需要检查aboutUsprivacy域名。

如果域名是https://two.com/aboutUshttps://two.com/privacy重定向到https://one.com/aboutUshttps://one.com/privacy.

我需要检查中间件。

谢谢。

laravel laravel-5

3
推荐指数
1
解决办法
6735
查看次数

如何在 Laravel 5.3 中的collect中使用groupBy之后的sortBy?

groupBy('date')我需要在使用 Eloquent、create和sortBy('price')in获取 sql 查询collectLaravel 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)

laravel laravel-5.3

2
推荐指数
1
解决办法
8147
查看次数

How to use nullable in foregin in Laravel?

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?

migration laravel laravel-5

2
推荐指数
1
解决办法
5109
查看次数

如何在Laravel中创建唯一索引?

我在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

如何创建唯一索引?

migration laravel laravel-5

2
推荐指数
1
解决办法
3092
查看次数

如何在laravel中的刀片中使用$ _GET变量?

我的框架是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 laravel-5.2

1
推荐指数
2
解决办法
3542
查看次数

如何在 Laravel 7 中创建多重身份验证?

我曾经使用 laravel 5.5 及早于https://github.com/Hesto/multi-auth

但此存储库不会针对 laravel 7.0 进行更新

如何在 Laravel 7.0 中创建多重身份验证?

laravel laravel-7

1
推荐指数
1
解决办法
5825
查看次数

如何在谷歌地图上的两点之间画一条线?

我需要在谷歌地图上的两点之间画一条曲线。

如何使用 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)

javascript jquery google-maps

0
推荐指数
1
解决办法
8181
查看次数

如何安装Laravel 5.4?

我听说Laravel 5.4将于明天公布.

如何安装(Laravel 5.4)Beta版?

你知道新功能吗?

laravel laravel-5.4

-11
推荐指数
3
解决办法
4万
查看次数