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; | |
use App\Articles\Repositories\Interfaces\ArticleRepositoryInterface; | |
use App\Articles\Requests\CreateArticleRequest; | |
use App\Http\Controllers\Controller; | |
class ArticlesApiController extends Controller | |
{ |
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; | |
use App\Articles\Requests\CreateArticleRequest; | |
use App\Http\Controllers\Controller; | |
class ArticlesApiController extends Controller | |
{ | |
/** |
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 Tests\Feature; | |
use Tests\TestCase; | |
class ArticleTest extends TestCase | |
{ | |
/** @test */ | |
public function it_can_create_an_article() |
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 | |
$attributes = $productAttributes | |
->pluck('attributesValues') | |
->flatten() | |
->unique() | |
->groupBy(function (AttributeValue $av) { | |
return $av->attribute->name; | |
}) | |
->map(function (Collection $collection) { |
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 | |
$receivedMessages = collect($user->receivedMessages)->sortByDesc($sort); // current code | |
// Refactor code | |
$user = User::find(1); | |
$userRepository = new UserRepository($user); | |
$receivedMessages = $userRepository->receivedMessages('desc'); | |
dd($receivedMessages); // message Collection; Same output with the current code |
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 App\Shop\Categories\Category; | |
use App\Shop\Products\Product; | |
use Illuminate\Database\Seeder; | |
class CategoryProductsTableSeeder extends Seeder | |
{ | |
public function run() | |
{ |
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; | |
use App\Articles\Article; | |
class ArticlesApiController extends Controller | |
{ | |
/** | |
* @param CreateArticleRequest $request |
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\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateArticlesTable extends Migration | |
{ | |
/** | |
* Run the migrations. |
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 Tests\Unit; | |
use Tests\TestCase; | |
class ArticleApiUnitTest extends TestCase | |
{ | |
public function it_can_create_an_article() | |
{ |
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; | |
use App\Articles\Article; | |
class ArticlesApiController extends Controller | |
{ | |
/** | |
* @param CreateArticleRequest $request |