Last active
October 4, 2019 08:15
-
-
Save MrAtiebatie/9e0a22f6cf132d6f17837d5ee28e1d49 to your computer and use it in GitHub Desktop.
This file contains 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\Repositories; | |
use App\Models\Product; | |
use MrAtiebatie\Repository; | |
use Illuminate\Database\Eloquent\Model; | |
/** | |
* Product repository | |
*/ | |
class ProductRepository extends Model | |
{ | |
use Repository; | |
/** | |
* The model being queried. | |
* | |
* @var \Illuminate\Database\Eloquent\Model | |
*/ | |
protected $model; | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
$this->model = app(Product::class); | |
} | |
/** | |
* Find published products by SKU | |
* @param {int} $sku | |
* @return {Product} | |
*/ | |
public function findBySku(int $sku): Product { | |
return this->whereIsPublished(1) | |
->whereSku($sku) | |
->first(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@felipefrancisco
Ahh came here to notice that :)