public function onSubmitData() { $bool = $this->checkifexists(); if ($bool != 0) { if (post('image') == null || post('title') == null || post('articleurl') == null || post('image') == 'No Image' || post('title') == 'No Title' || post('articleurl') == 'No Url') { return 'Error'; } // if ( $this->isImage(post('image')) && $this->isValidUrl(post('articleurl')) ) { $data['image'] = $image = trim(post('image')); $data['title'] = $title = trim(post('title')); $data['url'] = $url = trim(post('articleurl')); // }else{ // return 'Error'; // } $db = new Article(); $db->user_email = $data['email'] = Auth::getUser()->email; $db->user_name = $data['username'] = Auth::getUser()->name; $db->article_title = $title; $db->article_image = $image; $db->article_url = $url; $db->save(); $articles = Article::take($this->property('take'))->orderBy('id', 'desc')->get(); $this->articles = $articles; return 'OK'; } else { return 'Already'; } }
public function onSubmitData() { $data['result'] = 'Error'; if (isset(Auth::getUser()->email)) { } else { $data['message'] = 'Σύνδεση'; return $data; } if (post('image') && post('title') && post('articleurl')) { $data['image'] = $image = trim(post('image')); $data['posttitle'] = $title = trim(post('title')); $data['url'] = $url = preg_replace('/([^:])(\\/{2,})/', '$1/', trim(trim(post('articleurl'), '/'))); } else { $data['message'] = 'Πρόβλημα στο σύνδεσμο'; return $data; } $check1 = $this->checkifexists($url, $image, $title); if ($check1 == 0) { $data['message'] = 'Ήδη στο χρονολόγιο'; return $data; } $check2 = $this->isImage($image); if ($check2 == 0) { $data['message'] = 'Πρόβλημα με εικόνα'; return $data; } $check3 = $this->isTitle($title); if ($check3 == 0) { $data['message'] = 'Πρόβλημα με τίτλο'; return $data; } $db = new Article(); $db->user_id = Auth::getUser()->id; $db->user_email = $data['email'] = Auth::getUser()->email; $db->user_name = $data['username'] = Auth::getUser()->name; $db->article_title = $title; $db->article_image = $image; $db->article_url = $url; $db->save(); $articles = Article::with('user')->take($this->property('take'))->orderBy('id', 'desc')->get(); $this->articles = $articles; // return ['#wallmessages' => $this->renderPartial('ReadArticle::ArticleList')]; $data['result'] = 'Success'; $data['message'] = 'OK'; return $data; }