小编Sha*_*eem的帖子

如何在 Laravel 中写入 .txt 文件?

我想从数据库中获取 activationCode 的值,然后将其存储到 .txt 文件中。

这是我到目前为止所尝试的。

请帮忙!

注册控制器.php

  protected function create(array $data)
    {
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'phone' => $data['phone'],
            'password' => bcrypt($data['password']),
            'activationCode' => rand(1000,9999),
        ]);


     }


     public function put() {

         $user = User::where('is_active', 0)->get();

          $file = Storage::put( 'myfile.txt', $user);

   }
Run Code Online (Sandbox Code Playgroud)

php file read-write laravel-5.7

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

标签 统计

file ×1

laravel-5.7 ×1

php ×1

read-write ×1