コード例 #1
0
 public function store(Request $request, $intelligenceSlug)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $intelligence = Intelligence::where('slug', $intelligenceSlug)->firstOrFail();
     $tutorial = new Tutorial();
     $tutorial->user_id = Auth::user()->id;
     $tutorial->intelligence_id = $intelligence->id;
     $tutorial->title = $request->title;
     $tutorial->body = $request->body;
     $tutorial->save();
     //return $request->all();
     Flash::success('Tutorial creado exitosamente.');
     return redirect()->route('intelligence.show', $intelligenceSlug);
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::lists('id')->all();
     $tutorials = Tutorial::lists('id')->all();
     for ($i = 0; $i <= 10000; $i++) {
         factory('App\\Comment')->create(['user_id' => $users[array_rand($users)], 'tutorial_id' => $tutorials[array_rand($tutorials)]]);
     }
 }
コード例 #3
0
 public function index()
 {
     $articles = Article::all();
     $tutorials = Tutorial::all();
     $users = User::where('is_sitepoint', false)->get();
     $meetups = Meetup::all();
     $projects = Project::all();
     $bugs = Bugreport::all();
     return view('backend.pages.dashboard', compact('articles', 'tutorials', 'users', 'meetups', 'projects', 'bugs'));
 }
コード例 #4
0
 public function store(Request $request, $intelligenceSlug, $tutorialId)
 {
     $this->validate($request, ['message' => 'required']);
     $intelligence = Intelligence::where('slug', $intelligenceSlug)->firstOrFail();
     $tutorial = Tutorial::where('intelligence_id', $intelligence->id)->findOrFail($tutorialId);
     $comment = new Comment();
     $comment->user_id = Auth::user()->id;
     $comment->tutorial_id = $tutorial->id;
     $comment->message = $request->message;
     $comment->save();
     Flash::success('Comentario creado exitosamente.');
     return redirect()->back();
 }
コード例 #5
0
ファイル: Controller.php プロジェクト: AdrianKuriata/projekt
 public function updateTutorial($id, PanelTutorialRequest $request)
 {
     $tutorial = Tutorial::findOrFail($id);
     $tutorial->update(['title' => $request->input('title'), 'body' => $request->input('body')]);
     flash()->success('Udało Ci się edytować poradnik, oczekuj na informację zwrotną dotyczącą jego akceptacji.');
     return redirect('/paneltutorials');
 }
コード例 #6
0
 /**
  * @param $username
  * @param $slug
  * @return \Illuminate\Http\RedirectResponse
  */
 public function dislike($username, $slug)
 {
     if (Auth::check()) {
         $user = User::where('username', $username)->with('tutorials')->first();
         $article = Tutorial::where('user_id', $user->id)->where('slug', $slug)->first();
         $article->dislike(Auth::user());
         return redirect()->intended('@' . $article->user->username . '/tutorial/' . $article->slug);
     } else {
         alert()->warning('You need to sign in to dislike a tutorial', 'Whoops!');
         return redirect()->intended('auth/login');
     }
 }
コード例 #7
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $tutorial = Tutorials::where('id', $id)->get();
     return view('Tutorial.show')->with('tutorial', $tutorial);
 }
コード例 #8
0
ファイル: VideosController.php プロジェクト: jgt/ceprog
 public function dlTutorial($id, Request $request)
 {
     $tutorial = Tutorial::find($id);
     $public_path = public_path();
     $file = $public_path . '/tutoriales/' . $tutorial->original_filename;
     if ($file) {
         Archivo::delete($file);
         $tutorial->delete();
     }
     if ($request->ajax()) {
         return response()->json($tutorial);
     }
 }
コード例 #9
0
 public function addTutorial($id, AddTutorialRequest $request)
 {
     $tutorial = Tutorial::findOrFail($id);
     if ($request->input('accepted') == 1) {
         $tutorial->update(['title' => $request->input('title'), 'body' => $request->input('body'), 'accepted' => 1]);
         Notification::create(['not_title' => 'Kliknij i przejdź do panelu poradników, aby sprawdzić szczegóły', 'not_body' => 'Twój poradnik został zaakceptowany', 'not_status' => 3, 'not_from_user_name' => \Auth::user()->name, 'user_id' => $tutorial->user['id'], 'not_route' => '/paneltutorials']);
         flash()->success('Udało Ci się wprowadzić poradnik do bazy danych poradników.');
         return redirect('/admin/tutorials');
     } elseif ($request->input('accepted') == 0) {
         $tutorial->update(['title' => $request->input('title'), 'body' => $request->input('body'), 'accepted' => 0, 'notchecked_reason' => $request->input('notaccepted_reason')]);
         Notification::create(['not_title' => 'Kliknij i przejdź do panelu poradników, aby sprawdzić szczegóły', 'not_body' => 'Twój poradnik został odrzucony', 'not_status' => 3, 'not_from_user_name' => \Auth::user()->name, 'user_id' => $tutorial->user['id'], 'not_route' => '/paneltutorials']);
         flash()->success('Udało Ci się odrzucić poradnik, tworzący dostał odpowiedź zwrotną wraz z powodem odrzucenia.');
         return redirect('/admin/tutorials');
     }
 }
コード例 #10
0
 public function show($intelligenceSlug)
 {
     $intelligence = Intelligence::where('slug', $intelligenceSlug)->firstOrFail();
     $tutorials = Tutorial::where('intelligence_id', $intelligence->id)->orderBy('id', 'DESC')->paginate(10);
     return view('intelligence.show', compact('intelligence', 'tutorials'));
 }