示例#1
0
文件: Tag.php 项目: abada/xadmin
 private static function _save(Tag $tag, Request $request)
 {
     $tag->name = $request->get('name');
     $tag->slug = $request->get('slug') ? $request->get('slug') : str_slug($request->get('name'));
     $tag->type = $request->get('type');
     $tag->description = $request->get('description');
     $tag->parent_id = $request->get('parent_id') ? $request->get('parent_id') : 0;
     $tag->count = $request->get('count') ? $request->get('count') : 0;
     $tag->save();
     return $tag;
 }
示例#2
0
 public function category(Request $request)
 {
     $lastSegment = preg_split("/\\//", $request->url());
     $categorySlug = array_pop($lastSegment);
     // get the last segment on the current url
     $category = Tag::where('slug', $categorySlug)->first();
     // check if there is no category found.
     if (!$category) {
         return redirect()->route('front.error-404');
     }
     // condition where clause for parent categories or child.
     if ($category->parent_id == 0) {
         $field = 'tags.parent_id';
         $value = $category->id;
     } else {
         $field = 'tags.slug';
         $value = $category->slug;
     }
     // Get posts by PostTag slug or parent_id field
     $properties = Post::join('post_tags', 'posts.id', '=', 'post_tags.post_id')->join('tags', 'post_tags.tag_id', '=', 'tags.id')->where($field, $value)->select('posts.*', 'tags.name as tagName')->paginate(config('front.postPerPage'));
     $pageTitle = 'Category: ' . $category->name;
     if ($category->parent_id == 0) {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category') . '/' . $category->slug, 'name' => $category->name]];
     } else {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category', $category->parent()->slug), 'name' => $category->parent()->name], ['url' => route('front.category') . '/' . $category->parent()->slug . '/' . $category->slug, 'name' => $category->name]];
     }
     return view('properties', compact('properties', 'pageTitle', 'breadcrumbData'));
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $tag = Tag::where('id', $id)->first();
     if ($tag && $tag->delete()) {
         // Delete any reference from the PostTag.
         PostTag::where('tag_id', $id)->delete();
         return redirect()->back()->with('message', 'Deleted Successfully.');
     }
     return redirect()->back()->with('message', 'Unable to delete.');
 }
示例#4
0
 function _tagCategoryList($tags = array())
 {
     if (!$tags) {
         $tags = Tag::where('type', 'category')->where('parent_id', '!=', 0)->get();
     }
     $tagList[0] = "Please select";
     if (count($tags) > 0) {
         foreach ($tags as $tag) {
             if ($tag->type == 'category') {
                 $tagList[$tag->id] = $tag->name;
             }
         }
     }
     return $tagList;
 }
示例#5
0
文件: PostTag.php 项目: abada/xadmin
 public static function saveTags($tags, Post $post, $type)
 {
     // Remove all previous post and tag relationships
     $postTags = PostTag::where('post_id', $post->id)->where('type', $type)->delete();
     $tagGroup = explode(',', $tags);
     if ($tags) {
         foreach ($tagGroup as $key => $tagName) {
             $tag = Tag::where('name', $tagName)->first();
             // Refrain from insertion if the tag already exists.
             if (!$tag) {
                 $tag = Tag::create(['name' => $tagName, 'slug' => str_slug($tagName), 'type' => $type]);
             }
             // Create new post and tag relationships
             PostTag::create(['post_id' => $post->id, 'tag_id' => $tag->id, 'type' => $type]);
         }
     }
 }
示例#6
0
文件: TagRepo.php 项目: abada/xadmin
 public function subCategories($tagId)
 {
     return Tag::where('parent_id', $tagId)->where('type', 'category')->get();
 }
					
					<div class="clearfix"></div>
					
					<hr>
					
					<label for="geocomplete">Location Search</label>
					<input id="geocomplete" type="text" class="form-control" placeholder="Type in an address" name="meta[geo_location]" value="{{ _postMeta($post->id, 'geo_location') }}">
					<input id="find" type="button" class="btn btn-primary" value="Find Address" />    
					
					<div class="map_canvas"></div>
					<hr>
					
					<label for="geocomplete">Property Category</label>
					<div class="panel-group" id="accordion2">
						<?php 
$categoryList = \Xadmin\Models\Tag::where('type', 'category')->where('parent_id', 0)->get();
?>
						@forelse( $categoryList as $i => $category)
							<div class="panel panel-default">
								<div class="panel-heading">
									<h4 class="panel-title">
									<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#{{ str_slug( $category->name )}}">
									{{ $category->name }}
									</a>
									</h4>
								</div>
								<div id="{{ str_slug( $category->name )}}" class="panel-collapse collapse">
									<div class="panel-body">
										<div class="row">
										<?php 
$repo = new \Xadmin\Repositories\TagRepo();