示例#1
0
    }
})->before('auth');
Route::get('viewmore/unsave/yes/', function () {
    $petad_id = Input::get('id');
    // !!!important
    $sess_email = Session::get('pb_user_email');
    $user_id_main = User::where('email', '=', $sess_email)->first();
    $user_id = $user_id_main->id;
    // !!!important
    if (isset($petad_id)) {
        // delete the saved ad...
        $savead = Savead::where('petad_id', '=', $petad_id)->first();
        $savead_id = $savead->petad_id;
        $userid = Savead::where('user_id', '=', $user_id)->first();
        $userid_id = $userid->user_id;
        $unsavead = Savead::where('petad_id', '=', $petad_id)->orWhere('user_id', '=', $user_id)->first();
        if ($savead_id == $petad_id && $userid_id == $user_id) {
            $savead->delete();
            return Redirect::to('savingad?id=' . $petad_id)->with('welcome_back', 'You have successfully unsaved this pet ad.');
        }
    }
})->before('auth');
Route::get('unsavead', function () {
    return View::make('petads_user_guest_dashboard.unsavead');
})->before('auth');
/* other routes */
Route::post('imageupload@processing', array('uses' => 'ImageUploadController@image', 'as' => 'Fileupload.image'));
Route::post('imageupload@editing', array('uses' => 'ImageUploadController@edit', 'as' => 'Fileupload.image_edit'));
Route::post('imageupload@deleting', array('uses' => 'ImageUploadController@deleteimage', 'as' => 'Fileupload.deleteimage'));
Route::post('post@processing', array('uses' => 'PostController@petad', 'as' => 'Post.petad'));
/* /end secured pages only for members */
@extends('template.master_appidea_petads_general')
@section('content')
<div class="background">
<div class="row">
  <div class="small-12 medium-12 large-12 columns">
  	<div class="post-box-content">
  		<div class="row">
  			<div class="small-12 medium-12 large-8 columns">
  				<h3 class="text-left main-color-no-hover"><i class="fa fa-bookmark"></i> Saved ads</h3>
  				<hr>
          <?php 
$sess_email = Session::get('pb_user_email');
$user_id = User::where('email', '=', $sess_email)->first();
$user_id = $user_id->id;
$saved_ad_count = Savead::where('user_id', '=', $user_id)->count();
$saved_ad_lists = Savead::paginate(5);
$pet_ad_lists = $saved_ad_lists;
$naira = "₦";
?>

          <?php 
if ($saved_ad_count == 0) {
    echo '<div class="no-pet-ads">
              <h4 class="text-center"><i class="fa fa-bookmark orange-text"></i></h4>
              <h3 class="text-center">You have not saved any pet ad to your dashboard.</h3>
              <h5 class="text-center">Click the (<b>Saved this ad</b>) button to save a pet ad.</h5>
              <center>
                <a href="/ourads">
                <button id="save-pet-ad" style="" class="no-margin small pb-button-two-sides-all-save-ads bolder-text" type="button"><i class="fa fa-star-o fa-lg"></i> Save this ad</button>
                </a>
              </center>
                      </div>';
}
?>
         
                    {{ Form::close() }}
                    <a class="close-reveal-modal">&#215;</a>
                  </div>
                </div>
                <div class="list-box-con-two-expand">
                    <?php 
$saved_petad_id = Savead::where('petad_id', '=', $viewmore_id)->first();
//$saved_petad_id = $saved_petad_id->petad_id;
$saved_user_id = Savead::where('user_id', '=', $user_id)->first();
//$saved_user_id = $saved_user_id->user_id;
$saved_petad_id_count = Savead::where('petad_id', '=', $viewmore_id)->count();
$saved_user_id_count = Savead::where('user_id', '=', $user_id)->count();
if (Auth::check() == true) {
    // $saved_petad_id = $saved_petad_id->petad_id;
    // $saved_user_id = $saved_user_id->user_id;
    if ($saved_petad_id_count > 0 && $saved_user_id_count > 0) {
        echo '<a href="/unsavead?id=' . $viewmore_id . '"><button title="Click to unsave this pet ad" id="save-pet-ad" style="" class="no-margin wider-button small saved-petad-button bolder-text" type="button"><i class="fa fa-star fa-lg"></i> Saved</button></a>';
    } else {
        if ($saved_petad_id_count == 0) {
            echo '<a href="/savingad?id=' . $viewmore_id . '"><button id="save-pet-ad" style="" class="no-margin wider-button small pb-button-two-sides-all-save-ads bolder-text" type="button"><i class="fa fa-star-o fa-lg"></i> Save this ad</button></a>';
        }
    }
} else {
    echo '<a href="/login">
                        <button style="" class="no-margin wider-button small pb-button-two-sides-all-save-ads bolder-text" type="button"><i class="fa fa-star-o fa-lg"></i> Save this ad</button>
                      </a>';
}