/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //Getting the link to be edited so the form-model binder can pre-populate the form fields with old values
     $link = \App\Link::find($id);
     //Getting all parent links
     $links = (new \App\Link())->where('parent_id', '=', '0')->get();
     //Generating the dropdown list for parent pages as follows ['0' => 'No Parent', '1' => 'First Parent']
     $dropdown_links = dropdown_generator($links, ['id' => 'title'], ['0' => 'No Parent']);
     return view('panel.links.edit', compact('link', 'dropdown_links'));
 }
 public function deleteLink(Request $request)
 {
     // delete link if only the link belongs to the loggedin user
     $linkId = $request->get('id');
     $linkObject = Link::find($linkId);
     $linkObjectUserId = $linkObject->user_id;
     if ($linkObjectUserId == Auth::user()->id) {
         $linkObject->delete();
     }
 }
 public function freeCycle()
 {
     $card = $this->freeShuffle();
     $lid = $card->link_id;
     $directCount = $card->min_direct;
     $newCard = new static();
     $newCard->link_id = $lid;
     $newCard->min_direct = $directCount;
     $newCard->save();
     $cardline = new Cardline();
     $cardline->link_id = $lid;
     $newCard->cardpoints()->save($cardline);
     $this->deactivate($lid);
     // This will Broadcast To the Front End!
     $username = \App\Link::find($lid)->user->username;
     $data = ['event' => 'UserSignedUp', 'data' => ['username' => $username]];
     \PHPRedis::publish('rfn-chanel', json_encode($data));
 }
Exemple #4
0
 public function postUpdate(Requests\Admin\LinkRequest $request, $act, $id = 0)
 {
     $link = new Link();
     if ($act == 'edit') {
         $link = Link::find($id);
     }
     $link->title = $request->input('title');
     $link->description = $request->input('description');
     $link->image = $request->input('get_image');
     $link->url = $request->input('url');
     $link->order = $request->input('order');
     if ($link->save()) {
         $info = ['from' => 'update', 'status' => 'success'];
         j4flash($info);
         return redirect('admin/link');
     } else {
         return redirect()->back()->withErrors(['err' => lang('submit failed')])->withInput();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Link::truncate();
     if (!Link::find(1)) {
         DB::table('links')->insert(['link' => 'masterpowers', 'user_id' => 1, 'sp_link_id' => null, 'active' => true, 'date_activated' => \Carbon\Carbon::now(), 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     }
     // $faker = Faker\Factory::create();
     // foreach (range(1, 50) as $index) {
     //     Link::create([
     //         'link'           => str_replace('.', '_', $faker->unique()->userName),
     //         'user_id'        => $index + 1,
     //         'sp_link_id'     => $index,
     //         'sp_user_id'     => $index,
     //         'active'         => true,
     //         'date_activated' => \Carbon\Carbon::now(),
     //         'created_at'     => \Carbon\Carbon::now(),
     //         'updated_at'     => \Carbon\Carbon::now(),
     //     ]);
     // }
 }
 /**
  * [showRefLink description]
  * Route::get('{link?}', ['as' => 'reflink', 'uses' => 'LinkController@showRefLink']);
  *
  * @param [text] $link [referral link]
  *
  * @return [json] [all info about the link]
  */
 public function showRefLink($link = null)
 {
     //  // If it has a Sponsor Cookie
     if (\Cookie::has('sponsor')) {
         $cookie = \Cookie::get('sponsor');
         $link = $cookie['link'];
         $link = Link::findByLink($link)->load('user.profile');
         $product = Product::find(1);
         return view('pages.referralLink')->with(compact('link', 'product'));
     }
     // Check if the Provided Link is Valid  Redirect to Home if Invalid Link!
     try {
         $link = Link::findByLink($link);
         $sp_lid = $link->id;
         // If Sponsor is Not Active LeapFrog to ActiveSponsor
         if (!$link->active) {
             $sp_lid = $link->activeSponsor($sp_lid);
         }
         // Load User Profile
         $link = Link::find($sp_lid)->load('user.profile');
         $splink = [];
         $splink['id'] = $link->id;
         $splink['user_id'] = $link->user_id;
         $splink['link'] = $link->link;
         // Load Product
         $product = Product::find(1);
         // Assign $splink to the cookie
         // Note Cookie Wont Be Created if Exceeded More than 4kb
         // Cookie set Forever / 5 Years or until Cache Clear
         // No Needed To Return With Cookie if it is Queue
         $cookie = \Cookie::queue('sponsor', $splink, 2628000);
         // Return Referral View with Variable Link
         return view('pages.referralLink')->with(compact('link', 'product'));
         // LINK PROVIDED IS INVALID REDIRECT HOME
     } catch (ModelNotFoundException $e) {
         return Redirect::to('/');
     }
 }
Exemple #7
0
 /**
  * Display the JSON of the specified link
  *
  * @return Response
  */
 public function link($id)
 {
     $link = Link::find($id);
     return $link;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $link = Link::find($id);
     $link->delete();
     flash()->info('Link deleted successfully.');
     return redirect(route('backend'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $link = Link::find($id);
     if ($link->delete()) {
         echo 'true';
     } else {
         echo 'false';
     }
 }
Exemple #10
0
 /**
  * Increment hits counter.
  *
  * @param  int|Link $link
  */
 public function increment($link)
 {
     if (is_int($link)) {
         $link = Link::find($link);
     }
     $link->increment('hits');
 }
Exemple #11
0
 public function delete_links($course_id, $id)
 {
     $link = Link::find($id);
     deleteFromS3($link->link_icon);
     $link->delete();
     return redirect('manage/editcourse/' . $course_id);
 }
Exemple #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     //
     $link = Link::find($id);
     // If there is no link or if the link doesn't
     // belong to the user who is logged in
     if (!$link || $link->user->id !== Auth::user()->id) {
         // Display a 404 page
         abort(404);
     }
     $link->delete();
     return redirect('link')->with('flash_message', 'Your link was sucessfully deleted from your collection!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update($id)
 {
     $link = Link::find($id);
     $link->Rating -= 1;
     $link->save();
     // redirect
     Session::flash('message', 'Rating succesfully saved!');
     return Redirect::to('links');
 }
Exemple #14
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(LinkRequest $request, $id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $rq = $request->all();
     Link::find($id)->update($rq);
     $link_a_a = [];
     if (isset($rq['artist_id']) && is_array($rq['artist_id'])) {
         $rq['artist_id'] = array_unique($rq['artist_id'], SORT_NUMERIC);
         foreach ($rq['artist_id'] as $aid) {
             $link_a = ArtistLink::create(['artist_id' => $aid, 'link_id' => $id]);
             $link_a_a[] = $link_a->id;
         }
     }
     ArtistLink::where('link_id', $id)->whereNotIn('id', $link_a_a)->delete();
     $link_r_a = [];
     if (isset($rq['release_id']) && is_array($rq['release_id'])) {
         $rq['release_id'] = array_unique($rq['release_id'], SORT_NUMERIC);
         foreach ($rq['release_id'] as $rid) {
             $link_r = LinkRelease::create(['release_id' => $rid, 'link_id' => $id]);
             $link_r_a[] = $link_r->id;
         }
     }
     LinkRelease::where('link_id', $id)->whereNotIn('id', $link_r_a)->delete();
     $link_t_a = [];
     if (isset($rq['track_id']) && is_array($rq['track_id'])) {
         $rq['track_id'] = array_unique($rq['track_id'], SORT_NUMERIC);
         foreach ($rq['track_id'] as $tid) {
             $link_t = LinkTrack::create(['track_id' => $tid, 'link_id' => $id]);
             $link_t_a[] = $link_t->id;
         }
     }
     LinkTrack::where('link_id', $id)->whereNotIn('id', $link_t_a)->delete();
     return redirect()->route('link.show', ['link' => $id])->with('alert-success', [trans('htmusic.saved')]);
 }