Example #1
0
 /**
  * Store a newly created Post in storage.
  *
  * @param CreatePostRequest $request
  *
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $input = $request->all();
     $input['objectId'] = 'Post' . str_random(10);
     if ($request->file('image')) {
         $image = $this->uploadImage($request->file('image'), '/posts_photo/');
         $input['image'] = $image['resize_url'][0];
     }
     if ($request->file("audioFile")) {
         $input['audioFile'] = $this->uploadAudio($request->file('audioFile'), '/posts_audio/');
     }
     $post = $this->postRepository->create($input);
     $device_list = [];
     $gcm = Gcm::all();
     foreach ($gcm as $key => $value) {
         $device_list[] = PushNotification::Device($value->reg_id);
     }
     $message['title'] = $input['title'];
     $message['message'] = $input['content'];
     $devices = PushNotification::DeviceCollection($device_list);
     $message = PushNotification::Message(json_encode($message), array());
     $collection = PushNotification::app('appNameAndroid')->to($devices)->send($message);
     Flash::success('Post saved successfully.');
     return redirect(route('posts.index'));
 }
 /**
  * Store a newly created Post in storage.
  *
  * @param CreatePostRequest $request
  *
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $input = $request->all();
     $post = $this->postRepository->create($input);
     Flash::success('Post saved successfully.');
     return redirect(route('posts.index'));
 }
 /**
  * Store a newly created Post in storage.
  * POST /posts
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (sizeof(Post::$rules) > 0) {
         $this->validateRequestOrFail($request, Post::$rules);
     }
     $input = $request->all();
     $posts = $this->postRepository->create($input);
     return $this->sendResponse($posts->toArray(), "Post saved successfully");
 }
 /**
  * Store a newly created Post in storage.
  * POST /posts
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (sizeof(Post::$rules) > 0) {
         $this->validateRequestOrFail($request, Post::$rules);
     }
     $input = $request->all();
     $message['message'] = isset($input['content']) && $input['content'] ? $input['content'] : $input['content_mm'];
     $input['objectId'] = 'Post' . str_random(10);
     $input['postUploadNameMM'] = $input["postUploadName"];
     $input['content'] = isset($input['content']) && $input['content'] ? $input['content'] : 'This content is currently only available in Myanmar language.';
     $input['content_mm'] = isset($input['content_mm']) && $input['content_mm'] ? $input['content_mm'] : 'အဂၤလိပ္ ဘာသာစကားၿဖင့္သာ လက္ရွိတြင္ ေပးပိုု ့ထားပါသည္။';
     $posts = $this->postRepository->create($input);
     if ($posts->category_id == 'MqLh2pZShc' || $posts->category_id == 'DuXAXGFbEe') {
         $device_list = [];
         $gcm = Gcm::all();
         foreach ($gcm as $key => $value) {
             $device_list[] = PushNotification::Device($value->reg_id);
         }
         if ($posts->category_id == 'MqLh2pZShc') {
             $message['title'] = isset($input['content']) ? 'Market' : 'အေရာင္း / အ၀ယ္';
         } else {
             $message['title'] = isset($input['content']) ? 'Q&A' : 'အေမးအေျဖ';
         }
         $devices = PushNotification::DeviceCollection($device_list);
         $message = PushNotification::Message(json_encode($message), array());
         $collection = PushNotification::app('appNameAndroid')->to($devices)->send($message);
     }
     return $this->sendResponse($posts->toArray(), "Post saved successfully");
 }