diff --git a/app/Http/Controllers/ApiChromeExtensionController.php b/app/Http/Controllers/ApiChromeExtensionController.php index 9b196fd6..2abbcfdd 100644 --- a/app/Http/Controllers/ApiChromeExtensionController.php +++ b/app/Http/Controllers/ApiChromeExtensionController.php @@ -3,17 +3,14 @@ namespace App\Http\Controllers; use App\Domains\Sources\SourceTypeEnum; -use App\Http\Resources\CollectionCollection; -use App\Http\Resources\CollectionResource; use App\Models\Collection; use App\Models\Source; -use Illuminate\Http\Request; class ApiChromeExtensionController extends Controller { public function index() { - $collections = Collection::orderBy("name") + $collections = Collection::orderBy('name') ->paginate(20); return response()->json( @@ -22,7 +19,8 @@ public function index() } - public function createSource(Collection $collection) { + public function createSource(Collection $collection) + { $validated = request()->validate([ 'url' => 'required|string', 'recurring' => 'required|string', @@ -42,16 +40,16 @@ public function createSource(Collection $collection) { 'user_id' => auth()->user()->id, 'meta_data' => [ 'urls' => [ - $validated['url'] + $validated['url'], ], ], ]); - - return response()->json("OK"); + return response()->json('OK'); } - public function getSource(Collection $collection, Source $source) { + public function getSource(Collection $collection, Source $source) + { return response()->json( [ 'id' => $source->id, @@ -60,7 +58,7 @@ public function getSource(Collection $collection, Source $source) { 'active' => $source->active, 'recurring' => $source->recurring?->name, 'force' => $source->force, - 'status' => "non needed", + 'status' => 'non needed', 'type' => $source->type, 'collection_id' => $collection->id, 'url' => data_get($source->meta_data, 'urls.0'), @@ -68,7 +66,8 @@ public function getSource(Collection $collection, Source $source) { ); } - public function getSources() { + public function getSources() + { $sources = Source::orderBy('id') ->whereType(SourceTypeEnum::WebPageSource) ->with('collection') diff --git a/routes/web.php b/routes/web.php index 5581c81b..0ea033bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -117,7 +117,6 @@ function () { } ); - Route::controller(\App\Http\Controllers\AssistantEmailBoxSourceController::class)->group( function () { Route::get('/collections/{collection}/sources/email_source/create', 'create') diff --git a/tests/Feature/Http/Controllers/ApiChromeExtensionControllerTest.php b/tests/Feature/Http/Controllers/ApiChromeExtensionControllerTest.php index 6845f19e..a004063c 100644 --- a/tests/Feature/Http/Controllers/ApiChromeExtensionControllerTest.php +++ b/tests/Feature/Http/Controllers/ApiChromeExtensionControllerTest.php @@ -6,14 +6,10 @@ use App\Models\Collection; use App\Models\Source; use App\Models\User; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class ApiChromeExtensionControllerTest extends TestCase { - - public function test_index() { $user = User::factory()->create(); @@ -64,12 +60,11 @@ public function test_get_source() $this->assertEquals($source->id, $response['id']); $this->assertEquals($source->title, $response['title']); - $this->assertEquals($source->details, $response['details']); $this->assertEquals($source->details, $response['prompt']); $this->assertEquals($source->active, $response['active']); $this->assertEquals($source->recurring->name, $response['recurring']); $this->assertEquals($source->force, $response['force']); - $this->assertEquals("non needed", $response['status']); + $this->assertEquals('non needed', $response['status']); $this->assertEquals(data_get($source->meta_data, 'urls.0'), $response['url']); }