我试图保存一个被操纵的图像,我将他们推到s3.
我的代码有效此代码将图像直接保存在公共文件夹中*
public function store(Filesystem $filesystem)
{
$request = Input::all();
$validator = Validator::make($request, [
'images' => 'image'
]);
if ($validator->fails()) {
return response()->json(['upload' => 'false']);
}
$postId = $request['id'];
$files = $request['file'];
$media = [];
$watermark = Image::make(public_path('img/watermark.png'));
foreach($files as $file) {
$image = Image::make($file->getRealPath());
$image->crop(730, 547);
$image->insert($watermark, 'center');
$image->save($file->getClientOriginalName());
}
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的是能够将其保存在自己的文件夹中.首先,在公共文件夹的存储中,为博客文章存储图像的最佳位置是什么?但无论如何当我这样做:
$image->save('blogpost/' . $postId . '/' . $file->getClientOriginalName());
// Or this
$image->save(storage_path('app/blogpost/' . $postId . '/' . $file->getClientOriginalName()));
Run Code Online (Sandbox Code Playgroud)
我收到错误:
公共文件夹
Image.php第138行中的NotWritableException:无法将图像数据写入路径(blogpost/146/cars/image.jpg)
要么
存储路径 …
我已经进入了cartalyst/sentinel,并且我已经运行了生成表所需的迁移
php artisan migrate --package=cartalyst/sentinel
Run Code Online (Sandbox Code Playgroud)
我注意到这些是users表中可用的列
我想在电子邮件后添加用户名.所以我创建了一个迁移文件.
//add a column username after email in the users table
$table->string('username')->after('email')->unique();
Run Code Online (Sandbox Code Playgroud)
现在我使用Sentinel :: register
$credentials = Input::all();
$user = Sentinel::register($credentials);
Run Code Online (Sandbox Code Playgroud)
用户名不会保存在表格中.所以我设法通过编辑vendor/cartalyst/sentinel/src/Users/EloquentUser.php来获取它.
protected $fillable = [
'email',
'username', /* i added this */
'password',
'last_name',
'first_name',
'permissions',
];
Run Code Online (Sandbox Code Playgroud)
现在这个工作,用户名存储在表中.但我想知道我在做什么是对的?我们不应该触摸packages文件夹中的文件.我们如何解决这个问题?
我正在尝试通过laravel应用程序将文件上传到S3存储桶
我收到以下错误:
WrappedHttpHandler.php第152行中的S3Exception:在" https://s3-ap-southeast-1.amazonaws.com/上执行"PutObject"时出错
AWS HTTP错误:客户端错误:403 RequestTimeTooSkewed(客户端):请求时间与当前时间之间的差异太大
我做了一些研究,很多人说我机器的时间没有同步.我害怕乱糟糟的家园,因为我害怕破坏东西.我是否更改了我的应用时区?真的不确定.
请帮助并感谢您抽出宝贵时间
如何在不运行的情况下添加新网站?
homestead destroy
homestead up
Run Code Online (Sandbox Code Playgroud)
我使用Laravel Homestead版本2.0.13
当我添加一个新站点时,我将以下内容添加到我的homestead.yaml文件中
folders:
- map: ~/web/code
to: /code/websites
sites:
- map: laravel5.dev
to: /code/websites/laravel5/public
- map: anothersite.dev
to: /code/websites/anotherproject/public
Run Code Online (Sandbox Code Playgroud)
我已添加到我的主机文件中:
192.168.10.10 laravel5.dev
192.168.10.10 anothersite.dev
Run Code Online (Sandbox Code Playgroud)
然后我继续使用以下方法检查我的机器的状态:
vagrant global-status
90be623 default virtualbox running /Users/user/.composer/vendor/laravel/homestead
Run Code Online (Sandbox Code Playgroud)
我运行vagrant provision 90be623来配置我的新网站但遗憾的是anothersite.dev仍然指向laravel5.dev
我解决这个问题的唯一方法是运行宅基地摧毁,然后是宅基地.但这会破坏我的数据库.
当我运行流浪汉提供90be623我注意到很多次出现:
==> default: stdin: is not a tty (In red)
Run Code Online (Sandbox Code Playgroud)
当我做家园破坏和宅基地时,一切都是绿色的..
感谢您阅读本文并提供帮助:)
我正在学习如何使用Cartalyst/Sentinel.
我有
1)安装Laravel并导入包.运行迁移并生成必要的表.2)我创建了用户注册表和控制器
如果用户通过单击链接激活,则他们可以登录.
如果他们不激活他们不能(这是我想要的).
我的问题是我有以下方法试图捕获是否存在NotActivatedException.我想将用户重定向到主页,提醒用户该帐户未激活.但我得到Laravel错误消息而不是我的视图显示错误.这是我的代码.
public function postSignin(){
try {
// Validation
$validation = Validator::make(Input::all(), [
'email' => 'required|email',
'password' => 'required'
]);
if ($validation->fails()) {
return Redirect::route('signin')->withErrors($validation)->withInput();
}
$remember = (Input::get('remember') == 1) ? true : false;
if ($user = Sentinel::authenticate(Input::all(), $remember)) {
return Redirect::route('home')->with('global', 'Howdy ' . $user->username . '!');
}
$errors = 'Invalid Email / Password';
return Redirect::route('signin')->with('global', $errors);
} catch (NotActivatedException $e) {
$errors = 'Account not activated.';
return Redirect::route('signin')->with('global', $errors);
} …
Run Code Online (Sandbox Code Playgroud) 我已经在控制器中为登录表单编写了一些验证。
$validator = Validator::make(Input::all(), [
'email' => 'email|required',
'password' => 'required'
]);
// If validation fails
if($validator->fails()) {
// Redirect to some place
return Redirect::route('account-sign-in-get')->withErrors($validator)->withInput();
} else {
// Attempt to sign in
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我有以下几点:
@if($errors->has('email'))
<div class="alert alert-warning" role="alert">
{{ $errors->first('email') }}
</div>
@endif
Run Code Online (Sandbox Code Playgroud)
我输入一个字符串(不是有效的电子邮件地址),然后在提交时,我看到一个错误,指出:“电子邮件必须是有效的电子邮件地址”
相反,我得到:“电子邮件字段为必填”
{{ Form::open(['route' => 'account-sign-in-post', 'role' => 'form']) }}
<div class="form-group">
{{ Form::label('email', 'E-mail', ['for' => 'email', 'class' => 'sr-only ']) }}
{{ Form::text('username', NULL, ['placeholder' => 'Email', 'id' => 'email', 'class' => 'form-control']) …
Run Code Online (Sandbox Code Playgroud) 我是Cartalyst Sentinel的新手和ACL的概念.我设法创建了一个用户,执行激活,登录和注销.
我想把我的学习提升到一个新的水平.我想在这个laravel应用程序上有两种类型的用户.1是管理员另一个是订阅者.我假设我的帐户创建方法应该默认为用户创建一个订阅者.
public function postCreate() {
/* Validation */
$validation = Validator::make(Input::all(), [
'email' => 'required|email|max:50|unique:users',
'username' => 'required|min:3|max:20|unique:users',
'password' => 'required|min:6',
'password_repeat' => 'required|same:password',
]);
if ($validation->fails()) {
return Redirect('login')->withErrors($validation)->withInput();
} else {
$credentials = Input::all();
$user = Sentinel::register($credentials);
$activation = Activation::create($user);
$activation_code = $activation->code;
if ($user) {
Mail::send('emails.auth.activate', ['link' => URL::route('account-activate', [$user->id, $activation_code]), 'username' => $user->username], function($message) use ($user) {
$message->to($user->email, $user->username)->subject('Activate your account');
});
return Redirect::route('home')->with('global', 'Thank you for registering! We have sent you an email …
Run Code Online (Sandbox Code Playgroud) 我们正在尝试与Algolia实施即时搜索.它就像一个魅力.唯一的事情是我们想在每4次点击后添加一个clearfix div.现在是的
<div data-reactroot="" class="ais-hits">
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望每4个结果都有一个clearfix div,如下所示:
<div data-reactroot="" class="ais-hits">
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div>
<div class="ais-hits--item"></div><div class="clearfix"></div>
<div class="ais-hits--item"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是生成命中小部件的代码
search.addWidget(
instantsearch.widgets.hits({
container: '#booksearch',
templates: {
item: getTemplate('result')
},
cssClasses: {
item: 'col-lg-3 col-md-3 col-sm-3'
},
hitsPerPage: 12
})
);
search.start();
Run Code Online (Sandbox Code Playgroud)
感谢您抽出时间来阅读.
php ×5
laravel ×4
acl ×3
homestead ×2
laravel-4 ×2
laravel-5 ×2
algolia ×1
amazon-s3 ×1
image ×1
javascript ×1
laravel-5.2 ×1
search ×1
sentinel ×1
validation ×1