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\Shop\Base\Interfaces; | |
interface BaseRepositoryInterface | |
{ | |
public function create(array $attributes); | |
public function update(array $attributes, int $id); |
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\Shop\Base; | |
use App\Shop\Base\Interfaces\BaseRepositoryInterface; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Database\Eloquent\ModelNotFoundException; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
/** |
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 | |
use Illuminate\Http\UploadedFile; | |
class SomeController extends Controller { | |
// loop example | |
public function store(Request $request) | |
{ | |
if($request->hasFile('files')) { |
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\Http\Controllers\Api\v1; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
class PostController extends Controller | |
{ | |
public function index() |
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 | |
// your code | |
public function index() | |
{ | |
try { | |
$cards = Card::where('user_id',Auth::user()->id)->orderBy('created_at','desc')->get(); | |
return $cards; |
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 | |
'providers' => [ | |
/* | |
* Laravel Framework Service Providers... | |
*/ | |
... | |
App\Providers\RepositoryServiceProvider::class, | |
... |
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\Providers; | |
use App\Articles\Repositories\ArticlesRepository; | |
use App\Articles\Repositories\Interfaces\ArticleRepositoryInterface; | |
use Illuminate\Support\ServiceProvider; | |
class RepositoryServiceProvider extends ServiceProvider | |
{ |
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\Base; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Database\Eloquent\ModelNotFoundException; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
abstract class BaseRepository | |
{ |
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\Articles\Repositories; | |
use App\Articles\Article; | |
use App\Articles\Repositories\Interfaces\ArticleRepositoryInterface; | |
use App\Base\BaseRepository; | |
class ArticlesRepository extends BaseRepository implements ArticleRepositoryInterface | |
{ |
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\Articles\Repositories\Interfaces; | |
use App\Base\BaseRepositoryInterface; | |
interface ArticleRepositoryInterface extends BaseRepositoryInterface | |
{ | |
public function create(array $attributes); | |
} |