本文整理汇总了PHP中app\Category::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getAll方法的具体用法?PHP Category::getAll怎么用?PHP Category::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::getAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->middleware('auth');
if (Auth::user()) {
$this->favs = Fav::getAll();
$this->categories = Category::getAll();
}
}
示例2: questions
public function questions()
{
if (Auth::check()) {
$comments = Comment::whereHas('ad', function ($query) {
$query->where(['author_id' => Auth::user()->id, 'answer_to' => null]);
})->orWhereHas('answerTo', function ($query) {
$query->where('author_id', Auth::user()->id);
})->orderBy('created_at', 'desc')->get();
return view('profile.questions', ['categories' => Category::getAll(), 'comments' => $comments]);
} else {
return redirect('/');
}
}
示例3: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer(['layout', 'errors.layout', 'sub.filters'], function ($view) {
$new_questions = 0;
if (Auth::check()) {
$new_questions = Comment::where('is_viewed', false)->whereHas('ad', function ($query) {
$query->where(['author_id' => Auth::user()->id, 'answer_to' => null]);
})->orWhereHas('answerTo', function ($query) {
$query->where(['author_id' => Auth::user()->id]);
})->where('is_viewed', false)->count();
}
$view->with(['new_questions' => $new_questions, 'categories' => Category::getAll()]);
});
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(StoreAdRequest $request, $id)
{
$ad = Ad::findOrFail($id);
if (Gate::allows('update', $ad)) {
$isFree = $request['is_free'] == 'on';
$ad->update(['title' => $request['title'], 'text' => $request['text'], 'author_name' => $request['name'], 'phone' => $request['phone'], 'category_id' => $request['category_id'], 'city_id' => $request['city_id'], 'price' => $isFree ? 0 : $request['price'], 'is_free' => $isFree]);
/*
* Store the ad's images
*/
if ($request->has('images')) {
$imagesArr = [];
foreach ($request['images'] as $image) {
$imagePaths = explode('|', $image);
$imagesArr[] = ['ad_id' => $ad->id, 'small' => $imagePaths[0], 'big' => $imagePaths[1]];
}
AdImage::insert($imagesArr);
}
/*
* Update the ad's auto extra properties if received
*/
if ($request->has('make')) {
$autoExtraProperties = AutoExtraProperties::where('ad_id', $ad->id)->first();
$autoExtraProperties->update(['model_id' => $request['model'], 'year' => $request['year'], 'capacity' => $request['capacity'], 'engine_type' => $request['engine_type'], 'transmission' => $request['transmission'], 'mileage' => $request['mileage'], 'power' => $request['power']]);
}
/*
* Update the ad's realty extra properties if received
*/
if ($request->has('type_of_ad')) {
$realtyExtraProperties = RealtyExtraProperties::where('ad_id', $ad->id)->first();
$realtyExtraProperties->update(['type' => $request['type_of_ad'], 'lease' => $request['lease'], 'num_of_rooms' => $request['num_of_rooms'], 'square' => $request['square'], 'floor' => $request['floor'], 'num_of_floors' => $request['num_of_floors']]);
}
return view('publish', ['categories' => Category::getAll(), 'regions' => Region::getAllWithCities(), 'ad' => $ad, 'updated' => true]);
} else {
return redirect('/');
}
}
示例5: contacts
public function contacts()
{
return view('static.contacts', ['categories' => Category::getAll()]);
}