Created
August 1, 2016 15:23
-
-
Save Moccine/3ae299dda92d740e7e2f99f6345ddfa4 to your computer and use it in GitHub Desktop.
Share Link via Laravel Raw Raw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\Facades\Auth; | |
use Illuminate\Support\Facades\DB; | |
class Bookmark extends Model | |
{ | |
/** | |
* @var array | |
*/ | |
protected $fillable=['bm_url','category' ]; | |
/** | |
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |
*/ | |
public function user() | |
{ | |
return $this->belongsTo(User::class); | |
} | |
/** | |
* @param $id | |
* @return mixed | |
*/ | |
public static function getBookmark($id){ | |
return Bookmark::find($id); | |
} | |
/** | |
* @return mixed | |
*/ | |
public static function getBookmarks(){ | |
return DB::table('bookmarks')->orderBy('id', 'desc')->get(); | |
} | |
/** | |
* @return mixed | |
*/ | |
public static function getCategories(){ | |
return $categories=DB::table('bookmarks')->select ('category')->distinct()->get(); } | |
/** | |
* @param $category | |
* @return mixed | |
*/ | |
public function getCategoryBookmarks($category){ | |
$categoriess=DB::table('bookmarks')->where('category', $category)->get(); | |
return $categoriess; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment