Skip to content

Instantly share code, notes, and snippets.

@Moccine
Created August 1, 2016 15:23
Show Gist options
  • Save Moccine/3ae299dda92d740e7e2f99f6345ddfa4 to your computer and use it in GitHub Desktop.
Save Moccine/3ae299dda92d740e7e2f99f6345ddfa4 to your computer and use it in GitHub Desktop.
Share Link via Laravel Raw Raw
<?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