public function overview()
 {
     $data['inbox_count'] = Email::where('user_id', Auth::id())->where('box_id', 1)->count();
     //todo: if you want to write articles, contact us
     $articles = Article::where('user_id', Auth::id())->orderBy('id', 'asc')->get();
     $sites = Auth::user()->sites()->get();
     $professions = Auth::user()->professions()->get();
     $classifieds = Classified::where('user_id', Auth::id())->orderBy('id', 'desc')->get();
     return view('dashboard.overview', compact('data', 'articles', 'sites', 'professions', 'classifieds'));
 }
Exemple #2
0
 /**
  * Authorize the upload action of a picture album
  * see the route list for details
  *
  * @param $model
  * @param $model_id
  * @param $id
  *
  * @return bool
  */
 private function _authorize($model, $model_id, $id)
 {
     switch ($model) {
         case 'user':
             if ($id != 'new') {
                 $this->album = Album::where('id', $id)->first();
                 session(['album_id' => null]);
             } else {
                 if (session('album_id') && session('album_id') != null) {
                     $this->album = Album::where('id', session('album_id'))->first();
                 } else {
                     $this->makeNewAlbum();
                     Auth::user()->albums()->save($this->album);
                     $this->album->update(['user_id' => Auth::id()]);
                 }
             }
             break;
         case 'article':
             $this->article = Article::whereId($id)->first();
             if (!($this->album = Album::where('albumable_id', $id)->get()->first())) {
                 $this->makeNewAlbum();
                 $this->article->albums()->save($this->album);
             }
             break;
         case 'profession':
             $this->profession = Profession::whereId($id)->first();
             if (!($this->album = Album::where('albumable_id', $id)->get()->first())) {
                 $this->makeNewAlbum();
                 $this->profession->albums()->save($this->album);
             }
             break;
         case 'site':
             $this->site = Site::whereId($model_id)->first();
             if (!($this->album = Album::where('id', $id)->first())) {
                 if (!$this->site->albums->last()) {
                     $this->makeNewAlbum();
                     $this->site->albums()->save($this->site);
                 }
             }
             break;
         case 'classified':
             $this->classified = Classified::whereId($id)->first();
             if (!($this->classified = Album::where('albumable_id', $id)->get()->first())) {
                 $this->makeNewAlbum();
                 $this->classified->albums()->save($this->album);
             }
             break;
     }
     //session(['album_id' => $this->album->id]);
     return true;
 }
Exemple #3
0
 /**
  * Display the contact page to prepare and send an email.
  *
  * @param Request $request
  * @param         $model
  * @param         $id
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function contactModel(Request $request, $model, $id)
 {
     //first get the username of the logged in user
     $username = Helper::navbarUsername();
     //determine what model to use and what data to fetch
     $data = $this->_getModelAndId($model, $id, true);
     //something went wrong, redirect
     if (!$data) {
         return redirect()->back()->with(['error' => 'This ' . $model . ' does not exist!']);
     }
     $form = $this->formBuilder->create('App\\Http\\Forms\\ContactForm', ['method' => 'POST', 'url' => route('contact.email.posted')]);
     $form->add('model', 'hidden', ['value' => $model]);
     $form->add('id', 'hidden', ['value' => $id]);
     $form->add('send', 'submit', ['label' => 'Send this message', 'attr' => ['class' => 'btn btn-primary btn-block']]);
     if (isset($request['classified'])) {
         $add = Classified::whereId($request['classified'])->first();
         $title = 'Re: ' . str_limit($add->title, 34);
         $form->modify('subject', 'text', ['default_value' => $title]);
     }
     return view('contact.contact_' . $model, compact('username', 'model', 'data', 'form'));
 }
 /**
  * Execute the Command
  */
 public function handle()
 {
     return Classified::where('id', $this->id)->update(['title' => $this->title, 'category_id' => $this->category_id, 'description' => $this->description, 'price' => $this->price, 'condition' => $this->condition, 'main_image' => $this->main_image, 'location' => $this->location, 'email' => $this->email, 'phone' => $this->phone]);
 }
Exemple #5
0
 /**
  * @param $city_id
  * @param $category_id
  *
  * @return int
  */
 static function CityAddsCount($city_id, $category_id = null)
 {
     if ($category_id) {
         $count = Classified::where('classifieds.city_id', $city_id)->where('classifieds.category_id', $category_id)->count();
     } else {
         $count = Classified::where('classifieds.city_id', $city_id)->count();
     }
     if ($count) {
         return "({$count})";
     }
     return '<span class="light-grey">(' . $count . ')</span>';
 }
 /**
  * Execute the Command
  */
 public function handle()
 {
     return Classified::create(['title' => $this->title, 'category_id' => $this->category_id, 'description' => $this->description, 'price' => $this->price, 'condition' => $this->condition, 'main_image' => $this->main_image, 'location' => $this->location, 'email' => $this->email, 'phone' => $this->phone, 'owner_id' => $this->owner_id]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     // get this item
     $ad = Classified::find($id);
     if (Auth::user()->id != $ad->owner_id) {
         return back()->with('status', 'You cannot delete this item as you are not the owner.');
     }
     $ad->delete();
     return redirect('classifieds')->with('status', 'Listing was deleted.');
 }
 /**
  * @param Request $request
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function postSearch(Request $request)
 {
     $search = $request->all();
     $keyword = $search['query'];
     if (empty($keyword)) {
         return redirect(route('classified.search'))->with(['error' => 'No keyword given']);
     }
     $items = Classified::havingRaw(' title LIKE \'%' . $keyword . '%\' OR body LIKE \'%' . $keyword . '%\' ORDER BY publish_at DESC;')->get();
     if ($items->count()) {
         return view('classifieds.classified_search_results', compact('keyword', 'items'));
     }
     return redirect(route('classified.search'))->with(['error' => 'Search on \'' . $keyword . '\' has no results']);
 }