我在设计数据库(SQL/MySQL)时遇到问题.假设我们有一个用户,用户可以有很多朋友和很多帖子,并填写一些关于他自己的数据.
很明显,因为friends我们需要一个pivot_table用于n:n关系,因为posts我们需要创建一个带有user_id(1:n)关系的额外表.
所以我们需要users,user_friends并posts表.这很明显.这就是应该如何处理关系.
但现在让我们假设我们希望用户拥有以下数据:
name - text
description - text
marital status - select only one from list
favourite colour - select only one from list
hobby - select up to 3 from list
Run Code Online (Sandbox Code Playgroud)
对于文本字段(名称,描述),我们只需在users表中创建varchar/text列就可以了.
一般问题是:如何处理其他字段(从列表中选择)?我应该为它们创建关系,还是应该用它们创建标准数据列?
在我看来,没有必要为此创建关系表,因为使用列表(选择)我们只限制用户实际上可以粘贴到数据库中.理论上,我们可以允许用户手动输入他喜欢的颜色(例如red,如果他输入错误的东西,例如reds我们会比较它将允许的列表colours).性别也是如此 - 我认为,当我们只拥有女性和男性并为其创造关系时,创造额外的表格是没有意义的.
例如,我可以为属性创建以下列:
marital_status - int
fav_colour - int
hobby_1 - int
hobby_2 - int
hobby_3 - int
Run Code Online (Sandbox Code Playgroud)
还有另外一个表(甚至用PHP或其他语言的普通数组),我存储值为1的fav_colour例如是红色,值为2的爱好是音乐等等(我在这里存储这些值并不重要- 我也可以使用enum …
我不知道如果不粘贴所有文件的整个代码我是否可以解释这个问题,但我会尝试.
编辑我已将整个代码添加到Github Account - My Sass结构中
我使用Windows 8.1和Compass 0.12.6
在我的public_html文件夹中,我有config.rb文件和stylesheets文件夹.在stylesheets文件夹中,我有目录sass,我保存所有sass文件.CSS文件生成到样式表/预览文件夹(用于开发目的)和样式表文件夹(用于生产目的).
我运行罗盘观看我在public_html文件夹中运行的watch.bat脚本
watch.bat的内容是:
START compass watch -c config.rb -e development
START compass watch -c config.rb -e production
EXIT
Run Code Online (Sandbox Code Playgroud)
我的config.rb文件是:
require 'compass/import-once/activate'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "../"
sass_dir = "stylesheets/sass"
images_dir = "img"
javascripts_dir = "js"
cache = false
relative_assets = true
add_import_path "stylesheets/sass"
if environment == :development
css_dir = "stylesheets/preview"
line_comments = true
output_style = …Run Code Online (Sandbox Code Playgroud) 我发现有两种方法可以使用Laravel获取/显示模型的属性.我可以在User.php例如创建一个函数:
public function getUsername() {
return $this->username;
}
Run Code Online (Sandbox Code Playgroud)
然后显示如下的用户名:
{{{ Auth::user()->getUsername() }}}
Run Code Online (Sandbox Code Playgroud)
或者我可以简单地执行此操作而无需创建函数:
{{{ Auth::user()->username }}}
Run Code Online (Sandbox Code Playgroud)
这两种方法有什么区别?
因此,我在Github存储库中有以下分支:(遵循“ git flow”)
我已经知道如何创建分支别名,例如针对发行版。从技术上讲,composer.json每次我添加一个新的功能分支时都可以删除该文件,然后在准备将其合并到中时将其提交回来develop,但这将非常烦人并且容易忘记。
我的问题:如何隐藏Packagist的要素分支?
我可以包含一个.html文件而不是.phpLaravel 4 Blade吗?
我的代码:
@include('emails.templates.file')
//file is email.html
Run Code Online (Sandbox Code Playgroud)
file自动成为.php文件..
我正在构建一个Laravel 4.2应用程序,我正在使用Creolab的模块包.这是一个用于管理公司培训的应用程序,因此我的模块称为培训.一切顺利,除了保存新创建的培训.我提交"创建新表单"时收到的错误是:
Call to undefined method Roche\Trainings\Facades\TrainingFacade::save()
Run Code Online (Sandbox Code Playgroud)

这些是我的TrainingsController,Training Model,TrainingFacade,Trainings Service Provider和路线.我没有尝试似乎解决它.
嗨,我正在构建一个Laravel 5项目,该项目将部署在wordpress应用程序内的服务器上的子文件夹中(我不知道为什么,但客户端是客户端),然后我需要为应用程序中的所有路由添加前缀前缀如"/ es",现在的问题是与Auth相关的路由.在我的路线定义中,我有以下几行:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Run Code Online (Sandbox Code Playgroud)
我的问题是,有没有办法为这些路由添加前缀,而不必为从处理它们的特征中提取的auth控制器放置所有路由定义?
提前致谢.
所以我正在使用Laravel 5,我试图强制下载所选文件,但没有任何反应.
public function downloadUserFile(){
$result = $_POST['filename'];
$entry = File::where('filename', $result)->firstOrFail();
$file = Storage::disk()->get($entry->filePath);
$headers = array('Content-Type' => $entry->mimetype);
return response()->download(storage_path($entry->filePath), $result, $headers);
}
Run Code Online (Sandbox Code Playgroud)
并且响应头似乎没问题
Accept-Ranges: none
Cache-Control: public
Connection: Keep-Alive
Content-Disposition: attachment; filename="SIGNAL - Nadezdata.mp3"
Content-Length: 4205059
Content-Type: audio/mpeg
Run Code Online (Sandbox Code Playgroud)
你知道什么是错的吗?
因此,当我正在处理的 laravel 5 应用程序中创建新订单时,我试图记录一些简单的事情。
所以我有一个OrderWasCreated看起来像这样的事件:
<?php
namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use App\Order;
class OrderWasCreated extends Event
{
use SerializesModels;
public $order;
/**
* OrderWasCreated constructor.
*/
public function __construct(Order $order)
{
$this->order = $order;
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return [];
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有OrderEventListener它看起来像这样:
<?php
namespace App\Listeners;
use App\Events\OrderWasCreated;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderEventListener
{ …Run Code Online (Sandbox Code Playgroud) 我无法发送带有用户地址的电子邮件作为FROM和回复
在FormRequest中:
public function persist()
{
$reservation = Resa::create(
$this->only(['nom', 'email', 'phone', 'formule', 'date_arr', 'date_ret', 'nb_adu', 'nb_enf', 'lemessage'])
);
Mail::to('contact@cotiga.fr')
->from($reservation->email, $reservation->nom)
->replyTo($reservation->email, $reservation->nom)
->send(new Reservation($reservation));
}
Run Code Online (Sandbox Code Playgroud)
我有错误:
FatalThrowableError in ReservationForm.php line 48:
Call to undefined method Illuminate\Mail\PendingMail::from()
Run Code Online (Sandbox Code Playgroud)
我尝试了充分的可能性,但我无法改变字段FROM和REPLYTO你能帮助我吗?谢谢
laravel ×7
php ×6
laravel-5 ×4
attributes ×1
blade ×1
compass-sass ×1
composer-php ×1
database ×1
download ×1
eloquent ×1
events ×1
html ×1
include ×1
laravel-4 ×1
laravel-5.4 ×1
model ×1
mysql ×1
namespaces ×1
packagist ×1
sass ×1
sql ×1
view ×1