Пример #1
0
 /**
  * Display the specified category.
  *
  * @param  int $id
  * @return Response
  */
 public function show($alias, Advertisement $advertisement)
 {
     $category = Category::where('alias', $alias)->first();
     $ads = $advertisement->approved()->where('category_id', $category->id)->orderBy('id', 'desc')->paginate(3);
     return view('welcome', ['ads' => $ads]);
     //->nest('child','task.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Advertisement $ad, AdvertisementRequest $request)
 {
     $attachment = ImageUploadFacade::image($request->file('attachment'));
     $ad->fill($request->all())->attachment()->associate($attachment);
     $ad->save();
     return redirect()->route('admin.advertisement.index');
 }
Пример #3
0
 public function request(Advertisement $advertModel)
 {
     $b1_baner = Baner::where('type', 'b1')->get();
     $b2_baner = Baner::where('type', 'b2')->get();
     $latest_advert = $advertModel->get_last_advert();
     $top_advert = $advertModel->get_top_advert();
     $rules = ['name' => 'required', 'phone' => 'required', 'aid' => 'required'];
     $validator = JsValidator::make($rules);
     return view('site.request')->with('b1_baner', $b1_baner)->with('b2_baner', $b2_baner)->with('latest_advert', $latest_advert)->with('top_advert', $top_advert)->with('validator', $validator);
 }
Пример #4
0
 public function index(Advertisement $advertisement, Request $request)
 {
     $ads = $advertisement->approved()->orderBy('top', 'desc')->orderBy('id', 'desc');
     if ($_SERVER['HTTP_HOST'] == env('HOST')) {
         $ads = $ads->paginate(10);
     } else {
         $ads = $ads->paginate(20);
     }
     return view('welcome', compact('ads'));
 }
Пример #5
0
 public function my_answer($locale)
 {
     $user = Auth::user();
     $advert = Advertisement::where('published', 1)->whereHas('comments', function ($q) use($user) {
         $q->where('user_id', $user->id);
     })->has('category')->orderBy('created_at', 'desc')->paginate(20);
     return view('site.profile.my_answer')->with('advert', $advert);
 }
Пример #6
0
 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('favorites')->truncate();
     foreach (range(1, 30) as $index) {
         $ads = Advertisement::orderBy(DB::raw('RAND()'))->first();
         User::orderBy(DB::raw('RAND()'))->first()->favorites()->attach($ads->id);
     }
 }
Пример #7
0
 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('advertisement')->delete();
     foreach (range(1, 30) as $index) {
         $category_id = Category::orderBy(DB::raw('RAND()'))->first()->id;
         $city_id = Cities::orderBy(DB::raw('RAND()'))->first()->id;
         $type_id = AdType::orderBy(DB::raw('RAND()'))->first()->id;
         // $a_hash = AdsAttachment::orderBy(DB::raw('RAND()'))->first()->hash;
         Advertisement::create(['category_id' => $category_id, 'text' => $faker->paragraph(4), 'user_id' => 1, 'city_id' => $city_id, 'type_id' => $type_id, 'price' => 12345, 'approved' => rand(0, 1)]);
     }
 }
Пример #8
0
 public function is_my_adv($adv_id)
 {
     $adv = Advertisement::find($adv_id);
     if (!$adv) {
         return false;
     }
     if (!Auth::check()) {
         return false;
     }
     if ($adv->user_id != Auth::user()->id) {
         return false;
     }
     return true;
 }
 public function massApprove(Request $request)
 {
     $data = $request->input();
     if (array_key_exists('ads', $data)) {
         foreach ($data['ads'] as $id) {
             $ad = Advertisement::find($id);
             $ad->approved = 1;
             $ad->save();
         }
     }
 }
Пример #10
0
 public function edit($title)
 {
     $ads_seo_url = addslashes(strip_tags($title));
     $ads = Advertisement::with(['user', 'images'])->where('seo_url', $ads_seo_url)->first();
     return view('market.edit', ['ads' => $ads]);
 }
Пример #11
0
Route::post('getShop', ['uses' => 'ItemsCategoryController@getShop', 'as' => 'getShop']);
$router->post('/ads/flush', 'AdsController@flush');
$router->post('/questions/flush', 'QuestionsController@flush');
$router->post('/questions/upload', 'QuestionsController@store');
$router->post('/questions/{id}', 'QuestionsController@show');
$router->bind('pagename', function ($id) {
    return \AppAdmin\Models\PageName::find($id);
});
$router->bind('categories', function ($id) {
    return \App\Models\Category::find($id);
});
$router->bind('tags', function ($id) {
    return \App\Models\Tags::find($id);
});
$router->bind('ads', function ($id) {
    return \App\Models\Advertisement::find($id);
});
$router->bind('country', function ($title) {
    return \App\Models\Country::where('title', '=', $title)->first();
});
/**
 * PROFILE
 */
$router->bind('profile', function ($user_name) {
    $user = \App\Models\User::where('user_name', $user_name)->first();
    if (!$user) {
        $user = \App\Models\User::where('user_name', Auth::user()->user_name)->first();
    }
    return \ZaWeb\Profile\Models\Profile::where('user_id', $user->id)->first();
});
/**
Пример #12
0
 /**
  * @POST("/ads/{ads}/unpublish", middleware="auth", as="ads.unpublish")
  */
 public function unpublish(Advertisement $advertisement)
 {
     $advertisement->approved = 0;
     $advertisement->update();
     \Session::flash('message', 'Убрано с публикации.');
     return redirect()->back();
 }
Пример #13
0
 public function adverts_ajax()
 {
     $adverts = Advertisement::select('a.id', 'a.title', 'c.uk_title', 'u.name', 'a.created_at')->from('advertisements as a')->leftJoin('categories as c', 'c.id', '=', 'a.category_id')->leftJoin('users as u', 'u.id', '=', 'a.user_id');
     $action = '<a href="{{ URL::route( \'admin_adverts_update\', array("id"=>$id)) }}"><i class="fa fa-fw fa-edit"></i></a>
                 <a class="confirm-remove" href="{{ URL::route( \'admin_adverts_delete\', array("id"=>$id)) }}"><i class="fa fa-fw fa-remove"></i></a>
             ';
     return Datatables::of($adverts)->addColumn('action', $action)->make();
 }
Пример #14
0
 /**
  *
  * @param  int $id
  * @return Response
  * @Get("/{id}/approve",as="admin.advertisement.approve")
  */
 public function approve(Advertisement $advertisement)
 {
     $advertisement->approved = 1;
     $advertisement->save();
     return \Redirect::back();
 }
Пример #15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy(Advertisement $advertisement)
 {
     $advertisement->delete();
     return redirect()->route('admin.advertisement.index');
 }
Пример #16
0
 public function cancel_sug($id)
 {
     $adv = Advertisement::find($id);
     if (!$adv) {
         abort(404);
     }
     if ($adv->user_id != Auth::user()->id) {
         abort(404);
     }
     $adv->sel_comment = 0;
     $adv->status = 'default';
     $adv->save();
     return redirect()->back()->with('success', trans('message.comment_success_cancel'));
 }
Пример #17
0
 /**
  * @param Advertisement $advertisement
  * @param Request $request
  * @return mixed
  */
 public function index(Advertisement $advertisement, Request $request)
 {
     $ads = $advertisement::orderBy('top', 'desc')->orderBy('id', 'desc');
     $input = \Input::all();
     if ($request->input('search')) {
         $ads = $advertisement->where('text', 'LIKE', '%' . $request->input('search') . '%')->orderBy('top', 'desc')->orderBy('id', 'desc');
     }
     if ($request->input('category_id')) {
         if ($input['category_id'] != 'null') {
             $category = Category::findOrFail(\Input::get('category_id'));
             $ads = Advertisement::with('category')->where('category_id', '=', $category->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('city_id')) {
         if ($input['city_id'] != 'null') {
             $city = Cities::findOrFail(\Input::get('city_id'));
             $ads = Advertisement::with('city')->where('city_id', '=', $city->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('type_id')) {
         if ($input['type_id'] != 'null') {
             $type = AdType::findOrFail(\Input::get('type_id'));
             $ads = Advertisement::with('type')->where('type_id', '=', $type->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('category_id') && $request->input('type_id')) {
         if ($input['category_id'] != 'null' && $input['type_id'] != 'null') {
             $category = Category::findOrFail(\Input::get('category_id'));
             $type = AdType::findOrFail(\Input::get('type_id'));
             $ads = Advertisement::with('category')->with('type')->where('category_id', '=', $category->id)->where('type_id', '=', $type->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('city_id') && $request->input('category_id')) {
         if ($input['category_id'] != 'null' && $input['city_id'] != 'null') {
             $category = Category::findOrFail(\Input::get('category_id'));
             $city = Cities::findOrFail(\Input::get('city_id'));
             $ads = Advertisement::with('city')->with('category')->where('city_id', '=', $city->id)->where('category_id', '=', $category->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('city_id') && $request->input('type_id')) {
         if ($input['city_id'] != 'null' && $input['type_id'] != 'null') {
             $city = Cities::findOrFail(\Input::get('city_id'));
             $type = AdType::findOrFail(\Input::get('type_id'));
             $ads = Advertisement::with('city')->with('type')->where('city_id', '=', $city->id)->where('type_id', '=', $type->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($request->input('city_id') && $request->input('category_id') && $request->input('type_id')) {
         if ($input['category_id'] != 'null' && $input['city_id'] != 'null' && $input['type_id'] != 'null') {
             $category = Category::findOrFail(\Input::get('category_id'));
             $city = Cities::findOrFail(\Input::get('city_id'));
             $type = AdType::findOrFail(\Input::get('type_id'));
             $ads = Advertisement::with('city')->with('category')->with('type')->where('city_id', '=', $city->id)->where('category_id', '=', $category->id)->where('type_id', '=', $type->id)->orderBy('top', 'desc')->orderBy('id', 'desc');
         }
     }
     if ($_SERVER['HTTP_HOST'] == env('HOST')) {
         $ads = $ads->paginate(10);
     } else {
         $ads = $ads->paginate(20);
     }
     return View::make('welcome', compact('ads'))->with('input', \Input::all());
 }