Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $items = (array) json_decode($request->input('items'));
     $connections_name = json_decode($request->input('connections_name'));
     $names = json_decode($request->input('names'));
     $sizes = json_decode($request->input('sizes'));
     $dates = json_decode($request->input('dates'));
     $path_names = json_decode($request->input('path_name'));
     $tmp_url = substr(base64_encode(sha1(mt_rand())), 0, 16);
     $link = new Link();
     $link->link_name = $request->input('lkname');
     $link->user_id = Auth::user()->id;
     $link->url = $tmp_url;
     $link->save();
     $lid = $link->id;
     $random = User::find(Auth::user()->id)->token->first()->id;
     $root = File::create(['name' => 'root', 'path' => $request->input("lkname"), 'link_id' => $lid, 'token_id' => $random]);
     foreach ($items as $index => $item) {
         $tokenName = $connections_name[$index];
         $name = $names[$index];
         $path = $item;
         $size = $sizes[$index];
         $date = $dates[$index];
         $provObj = new Provider($tokenName);
         $share_link = $provObj->getLink($path);
         //            $before_dir = str_replace('/'.basename($path), "", $path);
         $root->children()->create(['name' => $name, 'path' => $path_names[$index], 'bytes' => 0, 'size' => $size, 'mime_type' => "", 'is_dir' => $size == "" ? true : false, 'shared' => $share_link, 'modified' => $date, 'token_id' => $provObj->getTokenId(), 'link_id' => $lid]);
     }
     return Redirect::to('/gtl/' . $request->input("lkname"));
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Validate the url format and uniquiness.
     $validator = Validator::make(Request::all(), ['url' => 'required|url|unique:links']);
     // If doesn't validate, redirect to the previous page
     // With errors and input for correction
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     // Create an instance of the link model
     $link = new Link();
     $link->url = Request::get('url');
     // Gets page title from the website
     $page_title = Request::get('title');
     // If can't recover the page title, show user a form to
     // Manually insert a page title
     if (empty($page_title)) {
         $page_title = $this->getPageTitleByUrl(Request::get('url'));
         if (empty($page_title)) {
             return redirect('link/create')->withInput()->withErrors($validator)->with('warning_message', 'You must manually add a title to this url!');
         }
     }
     // Everything is allright, put page title
     // in the link object
     $link->title = $page_title;
     $link->user()->associate(Auth::user());
     // Save everything in the database
     $link->save();
     // Return to index page and show message
     return redirect('link')->with('flash_message', 'Link added with success!');
 }
Exemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @Post("/")
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['expanded_link' => 'required|url|unique:links,expanded_link', 'go_link' => 'required|unique:links,go_link']);
     $link = new Link();
     $link->expanded_link = $request->input('expanded_link');
     $link->go_link = $request->input('go_link');
     $link->member_id = $request->member->id;
     $link->save();
     return response()->json($link);
 }
Exemplo n.º 4
0
 public function save(Request $request)
 {
     $form = $this->form(InternlinkSignupForm::class);
     $form->validate(Link::rules());
     if (!$form->isValid()) {
         return redirect()->back()->withErrors($form->getErrors())->withInput()->with('alert-warning', 'Error in form input!');
     }
     $link = new Link($request->all());
     $link->member_id = Auth::user()->member->id;
     $link->save();
     return redirect()->route('internlink.signup.internship');
 }
Exemplo n.º 5
0
 public function postlinkPOST(Request $request)
 {
     // only loggedin users can post links
     if (Auth::user()) {
         // Validate the Input
         $this->validate($request, ['link' => 'required|url', 'description' => 'required']);
         // Do stuff if validation is success
         $linkObject = new Link();
         $linkObject->url = $request->get('link');
         $linkObject->description = $request->get('description');
         $linkObject->user_id = Auth::user()->id;
         $linkObject->save();
         return redirect('home')->withMessage('Link added!');
     }
 }
Exemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\Prospect $request)
 {
     $activity = Activity::find($request->get('activity_id'));
     $prospect = new Prospect($request->all());
     $activity->prospects()->save($prospect);
     if ($request->has('links')) {
         foreach ($request->get('links') as $link) {
             $type = LinkType::findOrFail($link['type_id']);
             $link = new Link(['url' => $link['url']]);
             $link->prospect()->associate($prospect);
             $link->type()->associate($type);
             $link->save();
         }
     }
     return response()->json($prospect);
 }
 public function store(Request $request)
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('LinkURL' => 'required', 'Description' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('links/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $link = new Link();
         $link->LinkURL = Input::get('LinkURL');
         $link->Description = Input::get('Description');
         $link->UserID = Input::get('UserID');
         $link->save();
         // redirect
         Session::flash('message', 'Successfully created Link!');
         return Redirect::to('links');
     }
 }
Exemplo n.º 8
0
 private function storeLink(Request $request, $serial_id)
 {
     $link = strtolower($request->get('lastlink'));
     $title = !empty($request->get('titlelink')) ? strtolower($request->get('titlelink')) : null;
     $season = strtolower($request->get('season'));
     $serie = strtolower($request->get('serie'));
     $user_id = $request->user()->id;
     if (!empty($link) && !empty($serial_id)) {
         $Link = Link::where(['serial_id' => $serial_id, 'url' => $link])->get();
         // Если такой ссылки нет в базе даных
         if (!$Link->count()) {
             $NewLink = new Link();
             $NewLink->user_id = $user_id;
             $NewLink->serial_id = $serial_id;
             $NewLink->url = $link;
             $NewLink->season = $season;
             $NewLink->serie = $serie;
             $NewLink->title = $title;
             $NewLink->save();
         }
     } else {
         return response(['message' => 'Не обнаружена ссылка и/или ид сериала'], 422)->header('Content-Type', 'application/json');
     }
 }
Exemplo n.º 9
0
 public function processAdvert($campain_id)
 {
     $userName = Auth::user()->name;
     $campain = Campain::find($campain_id);
     $advert = $campain->advert;
     $response = "";
     try {
         $ml = new MonkeyLearn\Client('74312b126c6fcee32bddc68b6b3d4b15fee48868');
         $text_list = [$advert];
         $module_id = 'ex_eV2dppYE';
         $res = $ml->extractors->extract($module_id, $text_list);
         $results = $res->result;
         $response = $results[0];
     } catch (Exception $e) {
         echo 'Message: ' . $e->getMessage();
     }
     $colors = ['bg-success', 'bg-primary', 'bg-danger', 'bg-warning'];
     $keywords = [];
     foreach ($response as $item) {
         $text = $item["keyword"];
         $relevance = $item["relevance"];
         $isRegistered = 'Existente';
         $color = $colors[array_rand($colors)];
         $relevance = $relevance * 100 . "%";
         $keyword = Keyword::where('text', '=', $text)->get();
         if (count($keyword) == 0) {
             $isRegistered = 'Nuevo Registro';
             $keyword = new Keyword();
             $keyword->text = $text;
             $keyword->save();
         } else {
             $keyword = $keyword[0];
         }
         $link = new Link();
         $link->campain_id = $campain_id;
         $link->keyword_id = $keyword->id;
         $link->save();
         $keywords[] = ["text" => $text, "relevance" => $relevance, "isRegistered" => $isRegistered, "color" => $color];
     }
     return view('campain.result', ['userName' => $userName, 'textArticle' => $advert, 'keywords' => $keywords]);
 }
Exemplo n.º 10
0
 /**
  * @SWG\Post(
  *   path="/links",
  *   summary="Add a new link",
  *   @SWG\Response(
  *     response=200,
  *     description=""
  *   ),
  *   @SWG\Parameter(
  *     name="body",
  *     description="",
  *     in="body",
  *     schema=""
  *   )
  * )
  */
 public function store(Request $request)
 {
     $body = $request->json()->all();
     // JSON Request Body
     $body = (object) $body;
     $model = new Link();
     // Create an instance of our Eloquent Model
     if (isset($model::$rules)) {
         $this->validate($request, $model::$rules);
     }
     foreach ($this->postFields as $field) {
         $model->{$field} = @$body->{$field};
     }
     if ($model->save()) {
         $model = Link::findOrFail($model->id);
         return response()->json($model);
     }
     App::abort(500, 'Unable to save record');
 }