我们的服务器上有 CSV 文件,https://example.com/thisFIle.csv。这是从 Google Sheet 导出的数据。第三方网站每 3 分钟从该 CSV 文件获取一次数据。
我工作的公司是做预订业务的,所以他们的代理就是更新Google表格的人,然后我会将数据导出为CSV,然后上传到我们的服务器。
经过搜索,我了解到 Google Sheet 中有这个 google script 部分。我如何才能使用此谷歌脚本自动导出 CSV 然后手动上传到我们的服务器?
我在显示使用 spatie 媒体库上传的图像时遇到问题。我已经查看了他们的文档,但找不到解决方案。
我上传文件没有问题(仅限单个文件)。
控制器@商店
public function store(Request $request)
{
$categories = new ProductCategories();
$categories->name = $request->name;
$categories->slug = $request->slug;
$categories->description = $request->description;
if($request->hasFile('photo') && $request->file('photo')->isValid()){
$categories->addMediaFromRequest('photo')->toMediaCollection('category');
}
$categories->save();
$request->session()->flash('message', 'Successfully created category');
return redirect()->back();
}
Run Code Online (Sandbox Code Playgroud)
控制器@索引
public function index()
{
$lists = ProductCategories::all();
return view('dashboard\product_category\categoryList', [ 'lists' => $lists ]);
}
Run Code Online (Sandbox Code Playgroud)
config/filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => public_path('images/media'),
'url' => env('APP_URL').'/images/media',
'visibility' …
Run Code Online (Sandbox Code Playgroud) 我想创建一个具有特定角色的用户列表(如果给出多个角色,则为角色)
在我的用户控制器中
use DB;
use Auth;
use Storage;
use App\Role;
use App\HasRoles;
use App\User;
use App\Profile;
$users = User::with('roles')->where('name', 'admin')->get();
return view('dashboard.users.index', compact('users'));
Run Code Online (Sandbox Code Playgroud)
但我有这个错误
如果我 dd($users);
我可以看到角色在那里
我该如何解决这个问题?谢谢!
编辑:用户模型
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable, HasRoles;
protected $fillable = [
'name', 'email', 'phone_number', 'avatar', 'password', 'verification_code'
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
'phone_verified_at' => 'datetime',
];
public function profile()
{ …
Run Code Online (Sandbox Code Playgroud)