Пример #1
0
 public function store_blog_post(Request $request)
 {
     $id = $request->id;
     if ($id == -1) {
         $product = new Product();
     } else {
         $product = Product::find($id);
     }
     $product->description = $request->title;
     $product->type = $request->type;
     $product->rating = 0;
     $product->author_id = $this->user->id;
     $product->tags = $request->tags;
     $product->content = $request->blog_content;
     $product->category_id = $request->category_id;
     $avatar_type = $request->avatar_type;
     if ($avatar_type == 0) {
         $image_name = uploadFileToS3($request, 'avatar', 800, $product->image_name);
         if ($image_name != null) {
             $product->image_name = $image_name;
             $product->url = $this->s3_url . $image_name;
         }
         $thumb_name = uploadFileToS3($request, 'avatar', 250, $product->thumb_name);
         if ($thumb_name != null) {
             $product->thumb_name = $thumb_name;
             $product->thumb_url = $this->s3_url . $thumb_name;
         }
         $product->save();
         Session::flash('message', 'Bạn đã đăng bài viết thành công. <a href="' . url('bai-tap-colorme?id=' . $product->id) . '">Click vào đây để xem bài viết</a>');
     } else {
         if ($avatar_type == 1) {
             //            $video_name = uploadLargeFileToS3Useffmpec($request, 'product', $product->image_name);
             $video_name = uploadLargeFileToS3UseCloudConvert($request, 'avatar', $product->image_name);
             if ($video_name != null) {
                 $product->image_name = $video_name;
                 $product->url = $this->s3_url . $video_name;
                 $product->save();
                 Session::flash('message', 'Bạn đã đăng bài viết thành công');
             } else {
                 Session::flash('message', 'Có lỗi xảy ra');
             }
         }
     }
     return '<strong class="green-text">Đăng bài viết thành công</strong>';
 }
Пример #2
0
 public function store_video($topicId, Request $request)
 {
     $image = new Image();
     $image->owner_id = $this->user->id;
     $image->type = 1;
     $image_name = uploadLargeFileToS3UseCloudConvert($request, 'video', null);
     if ($image_name != null) {
         $image->name = $image_name;
         $image->url = $this->s3_url . $image_name;
     }
     $image->product_id = $request->product_id;
     if ($request->index == 0) {
         $product = Product::find($image->product_id);
         $product->url = $image->url;
         $product->image_name = $image->name;
         $product->save();
     }
     $image->save();
     $msg = ['message' => "Tải lên thành công"];
     return response()->json($msg, 200);
 }