小编ark*_*Dev的帖子

无法保存图像干预图像.Image.php第138行中的NotWritableException

我试图保存一个被操纵的图像,我将他们推到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)

要么

存储路径 …

php image laravel-5

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

Laravel Cartalyst Sentinel - 向用户表添加用户名列(正确的方法)

我已经进入了cartalyst/sentinel,并且我已经运行了生成表所需的迁移

php artisan migrate --package=cartalyst/sentinel
Run Code Online (Sandbox Code Playgroud)

我注意到这些是users表中可用的列

  1. ID
  2. 电子邮件
  3. 密码
  4. 权限
  5. 上次登录
  6. 名字
  7. created_at
  8. 的updated_at

我想在电子邮件后添加用户名.所以我创建了一个迁移文件.

//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文件夹中的文件.我们如何解决这个问题?

php acl laravel cartalyst-sentinel

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

Laravel 5 Amazon AWS S3错误:客户端错误:403 RequestTimeTooSkewed

我正在尝试通过laravel应用程序将文件上传到S3存储桶

我收到以下错误:

WrappedHttpHandler.php第152行中的S3Exception:在" https://s3-ap-southeast-1.amazonaws.com/上执行"PutObject"时出错

AWS HTTP错误:客户端错误:403 RequestTimeTooSkewed(客户端):请求时间与当前时间之间的差异太大

我做了一些研究,很多人说我机器的时间没有同步.我害怕乱糟糟的家园,因为我害怕破坏东西.我是否更改了我的应用时区?真的不确定.

请帮助并感谢您抽出宝贵时间

amazon-s3 amazon-web-services laravel-5 homestead

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

如何在不破坏环境的情况下在宅基地添加新的laravel站点?

如何在不运行的情况下添加新网站?

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)

当我做家园破坏和宅基地时,一切都是绿色的..

感谢您阅读本文并提供帮助:)

php laravel homestead

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

无法在Laravel中捕获Cartalyst\Sentinel\Checkpoints\NotActivatedException

我正在学习如何使用Cartalyst/Sentinel.

我有

1)安装Laravel并导入包.运行迁移并生成必要的表.2)我创建了用户注册表和控制器

  1. 创建一条记录
  2. 创建激活码
  3. 向用户发送包含激活链接的电子邮件.

如果用户通过单击链接激活,则他们可以登录.

如果他们不激活他们不能​​(这是我想要的).

我的问题是我有以下方法试图捕获是否存在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)

php acl laravel laravel-4

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

Laravel电子邮件验证显示错误消息

我已经在控制器中为登录表单编写了一些验证。

$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)

php validation laravel

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

Cartalyst Sentinel Laravel - 你如何创造角色?

我是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)

acl sentinel laravel-4

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

如何在每4次点击Algolia后添加一个clearfix div?

我们正在尝试与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)

感谢您抽出时间来阅读.

javascript search algolia laravel-5.2

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