Exemplo n.º 1
0
 /**
  * Responds to requests to POST /reviews/{id}/create
  */
 public function postCreate(Request $request, $id = null)
 {
     $landmark = \App\Landmark::find($id);
     if (is_null($landmark)) {
         \Session::flash('flash_message', 'Landmark not found.');
         return redirect('\\landmarks');
     }
     $this->validate($request, ['review' => 'required|min:1']);
     # Enter review
     $review = new \App\Review();
     $review->landmark()->associate($landmark->id);
     $review->user()->associate(\Auth::id());
     # <--- NEW LINE
     $review->review = $request->review;
     $review->save();
     # Done
     \Session::flash('flash_message', 'Your review was added!');
     return redirect('/reviews');
 }
Exemplo n.º 2
0
 /**
  * Responds to requests to POST /photos/{id}/create
  */
 public function postCreate(Request $request, $id = null)
 {
     $landmark = \App\Landmark::find($id);
     if (is_null($landmark)) {
         \Session::flash('flash_message', 'Landmark not found.');
         return redirect('\\landmarks');
     }
     if (\App\Photo::where('filepath', '=', $request->filepath)->exists()) {
         \Session::flash('flash_message', 'A Photo with that URL already exists in our database.');
         return redirect('/photos/' . $id);
     }
     $this->validate($request, ['filepath' => 'required|url', 'photo_description' => 'required|min:1']);
     # Enter photo
     $photo = new \App\Photo();
     $photo->landmark()->associate($landmark->id);
     $photo->user()->associate(\Auth::id());
     # <--- NEW LINE
     $photo->filepath = $request->filepath;
     $photo->photo_description = $request->photo_description;
     $photo->save();
     # Done
     \Session::flash('flash_message', 'Your photo was added!');
     return redirect('/photos/' . $id);
 }
Exemplo n.º 3
0
 /**
  *
  */
 public function getDoDelete($landmark_id)
 {
     $landmark = \App\Landmark::find($landmark_id);
     if (is_null($landmark)) {
         \Session::flash('flash_message', 'Landmark not found.');
         return redirect('\\landmarks');
     }
     if ($landmark->tags()) {
         $landmark->tags()->detach();
     }
     $landmark->delete();
     \Session::flash('flash_message', $landmark->name . ' was deleted.');
     return redirect('/landmarks');
 }
Exemplo n.º 4
0
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WelcomeController@getIndex');
if (App::environment('local')) {
    Route::get('/drop', function () {
        DB::statement('DROP database yolo');
        DB::statement('CREATE database yolo');
        return 'Dropped yolo; created yolo.';
    });
    Route::get('/workspace', function () {
        $landmark = \App\Landmark::find(1);
        $tags = $landmark->tags;
        dd($tags);
    });
    Route::get('/debug', function () {
        echo '<pre>';
        echo '<h1>Environment</h1>';
        echo App::environment() . '</h1>';
        echo '<h1>Debugging?</h1>';
        if (config('app.debug')) {
            echo "Yes";
        } else {
            echo "No";
        }
        echo '<h1>Database Config</h1>';
        /*