示例#1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function findAll()
 {
     $token = Input::get('token', '');
     if ($token != '') {
         $compare = GlobalLibrary::compareToken($token);
         if ($compare) {
             $dataAll = table_content::get();
             $dataConverted = array();
             $app = app();
             $i = 0;
             foreach ($dataAll as $row) {
                 $dataConverted[$i] = $app->make('stdClass');
                 $dataConverted[$i]->id = $row->content_id;
                 $dataConverted[$i]->ttl = $row->content_title;
                 $dataConverted[$i]->det = $row->content_detail;
                 $dataConverted[$i]->med = $row->content_media_id;
                 $dataConverted[$i]->upl = $row->content_users_uploader;
                 $dataConverted[$i]->las = $row->content_last_editor;
                 $dataConverted[$i]->ins = $row->content_date_insert;
                 $dataConverted[$i]->upd = $row->content_date_update;
                 $dataConverted[$i]->exp = $row->content_date_expired;
                 $dataConverted[$i]->pub = $row->content_publish;
                 $dataConverted[$i]->cat = $row->content_category_id;
                 $dataConverted[$i]->rep = $row->content_repost_from;
                 $i++;
             }
             return (new Response(array('status' => true, 'data' => $dataConverted), 200))->header('Content-Type', "json");
         } else {
             return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json");
         }
     } else {
         return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json");
     }
 }
示例#2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $token = Input::get('token', '');
     if ($token != '') {
         $compare = GlobalLibrary::compareToken($token);
         if ($compare) {
             $ttl = Input::get('ttl', '');
             $hea = Input::get('hea', '');
             $det = Input::get('det', '');
             $med = Input::get('med', '');
             $upl = Input::get('upl', '');
             $las = Input::get('las', '');
             $ins = Input::get('ins', '');
             $upd = Input::get('upd', '');
             $exp = Input::get('exp', '');
             $pub = Input::get('pub', '');
             $cat = Input::get('cat', '');
             $rep = Input::get('rep', '');
             $field_user_detail = array('content_title' => $ttl, 'content_headline' => $hea, 'content_detail' => $det, 'content_media_id' => $med, 'content_users_uploader' => $upl, 'content_last_editor' => $las, 'content_date_insert' => $ins, 'content_date_update' => $upd, 'content_date_expired' => $exp, 'content_publish' => $pub, 'content_category_id' => $cat, 'content_repost_from' => $rep);
             $user = table_content::create($field_user_detail);
             return (new Response(array('status' => true, 'msg' => 'Register successfully'), 200))->header('Content-Type', "json");
         } else {
             return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json");
         }
     } else {
         return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json");
     }
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     table_content::find($id)->delete();
     return redirect('admin/content')->with('warning', 'Data have been removed!');
 }
示例#4
0
 public function repost()
 {
     $app = app();
     if (Request::has('token')) {
         $token = Request::input('token', '');
         $compare = GlobalLibrary::tokenExtractor($token);
         $users_checker = GlobalLibrary::CheckUsersToken($compare);
         //echo '<pre>'.print_r($compare).'</pre>';
         if ($users_checker[0]) {
             $uname = $users_checker[1];
             $uid = $users_checker[2];
             $email = $users_checker[3];
             if (Request::input('cid') == null) {
                 return (new Response(array('status' => true, 'msg' => 'Please select a content that you want to repost '), 200))->header('content-Type', "json");
             } else {
                 //get content resource
                 $target = table_content::where('content_id', '=', Request::input('cid'))->first();
                 //input content
                 $field_content = array('content_title' => $target->content_title, 'content_headline' => $target->headline, 'content_detail' => $target->content_detail, 'content_media_id' => $target->content_media_id, 'content_users_uploader' => $uid, 'content_last_editor' => $target->content_last_editor, 'content_date_insert' => date('Y-m-d H:i:s'), 'content_date_expired' => $target->content_date_expired, 'content_publish' => $target->content_publish, 'content_category_id' => $target->content_category_id, 'content_hashtag_id' => $target->content_hashtag_id, 'content_repost_from' => $target->content_id);
                 $content = table_content::create($field_content);
                 //notification repost
                 //input content
                 $field_notiication = array('users_id' => $target->content_users_uploader, 'datetime' => date('Y-m-d H:i:s'), 'status' => 'send');
                 $content = table_notification::create($field_notiication);
                 /*
                 //it always return 1 iterate. i made it but i don't know where a message of notiication store?
                  $dataConverted = array();
                  $app = app();
                  $i=0;
                 $whorepost = table_users_detail::where('users_id', '=',$uid)->first();
                 foreach($whorepost as $row){
                     $dataConverted[$i]->uid = $row->users_id; //send user ID who repost his/her content
                     $dataConverted[$i]->unm = $row->users_name; //send user Name who repost his/her content
                     $dataConverted[$i]->ttl = $target->content_title; //send the Title that reposted
                     $dataConverted[$i]->nci = $whorepost; //send the new content ID to him/her 
                     $dataConverted[$i]->cdi = date('Y-m-d H:i:s'); //send the date repost (insert)
                 
                 }
                 */
                 return (new Response(array('status' => true, 'msg' => 'success'), 200))->header('content-Type', "json");
             }
         } else {
             return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('content-Type', "json");
         }
     } else {
         return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('content-Type', "json");
     }
 }