Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Use whereLike for search so MySQL works alongside PostgreSQL (#302)
Jamie Ontiveros6e10e394a973
diff --git a/app/Actions/Media/ListWorkspaceAssets.php b/app/Actions/Media/ListWorkspaceAssets.phpindex 08833e859..6cc36904c 100644--- a/app/Actions/Media/ListWorkspaceAssets.php+++ b/app/Actions/Media/ListWorkspaceAssets.php@@ -27,7 +27,7 @@ class ListWorkspaceAssets->where('mediable_type', Relation::getMorphAlias(Workspace::class))->where('mediable_id', $workspace->id)->where('collection', 'assets')- ->when(filled($search), fn (Builder $query) => $query->where('original_filename', 'ilike', '%'.trim($search).'%'))+ ->when(filled($search), fn (Builder $query) => $query->whereLike('original_filename', '%'.trim($search).'%'))->when(filled($type), fn (Builder $query) => $query->where('type', $type))->latest()->orderByDesc('id');diff --git a/app/Http/Controllers/App/AssetController.php b/app/Http/Controllers/App/AssetController.phpindex e6a772cee..e88a2dd33 100644--- a/app/Http/Controllers/App/AssetController.php+++ b/app/Http/Controllers/App/AssetController.php@@ -48,7 +48,7 @@ class AssetController extends Controller$type = $request->input('type');$assets = $workspace->getMedia('assets')- ->when($term !== '', fn ($query) => $query->where('original_filename', 'ilike', '%'.$term.'%'))+ ->when($term !== '', fn ($query) => $query->whereLike('original_filename', '%'.$term.'%'))->when(in_array($type, ['image', 'video'], true), fn ($query) => $query->where('type', $type))->latest()->paginate(config('app.pagination.default'));diff --git a/app/Http/Controllers/App/PostController.php b/app/Http/Controllers/App/PostController.phpindex 61981c895..c0ff2b59b 100644--- a/app/Http/Controllers/App/PostController.php+++ b/app/Http/Controllers/App/PostController.php@@ -58,7 +58,7 @@ class PostController extends Controller}if ($search = $request->input('search')) {- $query->where('content', 'ilike', "%{$search}%");+ $query->whereLike('content', "%{$search}%");}$labelIds = $request->collect('labels')diff --git a/app/Http/Controllers/App/WorkspaceController.php b/app/Http/Controllers/App/WorkspaceController.phpindex ecc1c6e4d..74db86f69 100644--- a/app/Http/Controllers/App/WorkspaceController.php+++ b/app/Http/Controllers/App/WorkspaceController.php@@ -42,7 +42,7 @@ class WorkspaceController extends Controller$members = $workspace->members()->where('users.id', '!=', $request->user()->id)- ->when($term !== '', fn ($query) => $query->where('users.name', 'ilike', '%'.$term.'%'))+ ->when($term !== '', fn ($query) => $query->whereLike('users.name', '%'.$term.'%'))->orderBy('users.name')->limit(50)->get(['users.id', 'users.name', 'users.email']);diff --git a/app/Http/Controllers/App/WorkspaceLabelController.php b/app/Http/Controllers/App/WorkspaceLabelController.phpindex bd904c221..137290000 100644--- a/app/Http/Controllers/App/WorkspaceLabelController.php+++ b/app/Http/Controllers/App/WorkspaceLabelController.php@@ -26,7 +26,7 @@ class WorkspaceLabelController extends Controller$this->authorize('createPost', $workspace);$labels = $workspace->labels()- ->when($request->input('search'), fn ($query, $search) => $query->where('name', 'ilike', "%{$search}%"))+ ->when($request->input('search'), fn ($query, $search) => $query->whereLike('name', "%{$search}%"))->latest()->paginate(config('app.pagination.default'));diff --git a/app/Http/Controllers/App/WorkspaceSignatureController.php b/app/Http/Controllers/App/WorkspaceSignatureController.phpindex f0d583ca2..281940025 100644--- a/app/Http/Controllers/App/WorkspaceSignatureController.php+++ b/app/Http/Controllers/App/WorkspaceSignatureController.php@@ -26,7 +26,7 @@ class WorkspaceSignatureController extends Controller$this->authorize('createPost', $workspace);$signatures = $workspace->signatures()- ->when($request->input('search'), fn ($query, $search) => $query->where('name', 'ilike', "%{$search}%"))+ ->when($request->input('search'), fn ($query, $search) => $query->whereLike('name', "%{$search}%"))->latest()->paginate(config('app.pagination.default'));diff --git a/app/Mcp/Tools/Post/ListPostsTool.php b/app/Mcp/Tools/Post/ListPostsTool.phpindex 68d3bc5ea..c95d07c97 100644--- a/app/Mcp/Tools/Post/ListPostsTool.php+++ b/app/Mcp/Tools/Post/ListPostsTool.php@@ -45,7 +45,7 @@ class ListPostsTool extends Tool};if ($search = data_get($validated, 'search')) {- $query->where('content', 'ilike', '%'.$search.'%');+ $query->whereLike('content', '%'.$search.'%');}$posts = $query->latest('scheduled_at')diff --git a/tests/Feature/Api/AssetApiTest.php b/tests/Feature/Api/AssetApiTest.phpindex c4ad4d4bb..f048e682c 100644--- a/tests/Feature/Api/AssetApiTest.php+++ b/tests/Feature/Api/AssetApiTest.php@@ -66,6 +66,25 @@ test('filters assets by filename search and type', function () {->assertJsonPath('data.0.original_filename', 'campaign-hero.jpg');});+test('filters assets by filename search case-insensitively', function () {+ Media::factory()->assets()->create([+ 'mediable_type' => (new Workspace)->getMorphClass(),+ 'mediable_id' => $this->workspace->id,+ 'original_filename' => 'CAMPAIGN-Hero.jpg',+ ]);+ Media::factory()->assets()->create([+ 'mediable_type' => (new Workspace)->getMorphClass(),+ 'mediable_id' => $this->workspace->id,+ 'original_filename' => 'office-shot.jpg',+ ]);++ $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])+ ->getJson(route('api.assets.index', ['search' => 'campaign-hero']))+ ->assertOk()+ ->assertJsonCount(1, 'data')+ ->assertJsonPath('data.0.original_filename', 'CAMPAIGN-Hero.jpg');+});+test('paginates assets with the application page size', function () {$perPage = (int) config('app.pagination.default');diff --git a/tests/Feature/AssetControllerTest.php b/tests/Feature/AssetControllerTest.phpindex f124ed3dc..2bfb196cb 100644--- a/tests/Feature/AssetControllerTest.php+++ b/tests/Feature/AssetControllerTest.php@@ -61,6 +61,18 @@ test('assets search returns paginated json filtered by name', function () {$response->assertJsonPath('data.0.id', $matching->id);});+test('assets search matches filenames case-insensitively', function () {+ $matching = $this->workspace->addMedia(UploadedFile::fake()->image('VACATION-Beach.jpg'), 'assets');+ $this->workspace->addMedia(UploadedFile::fake()->image('office-shot.jpg'), 'assets');++ $response = $this->actingAs($this->user)+ ->getJson(route('app.assets.search', ['search' => 'vacation']));++ $response->assertOk();+ $response->assertJsonCount(1, 'data');+ $response->assertJsonPath('data.0.id', $matching->id);+});+test('assets search filters by type', function () {$this->workspace->addMedia(UploadedFile::fake()->image('photo.jpg'), 'assets');$this->workspace->addMedia(UploadedFile::fake()->create('clip.mp4', 100, 'video/mp4'), 'assets');diff --git a/tests/Feature/Mcp/PostToolTest.php b/tests/Feature/Mcp/PostToolTest.phpindex fa1937186..bcdd24042 100644--- a/tests/Feature/Mcp/PostToolTest.php+++ b/tests/Feature/Mcp/PostToolTest.php@@ -65,6 +65,50 @@ test('list posts only returns own workspace posts', function () {});});+test('list posts filters by content search', function () {+ $matching = Post::factory()->create([+ 'workspace_id' => $this->workspace->id,+ 'user_id' => $this->user->id,+ 'content' => 'Hello marketing world',+ ]);+ Post::factory()->create([+ 'workspace_id' => $this->workspace->id,+ 'user_id' => $this->user->id,+ 'content' => 'Something else entirely',+ ]);++ $response = TryPostServer::actingAs($this->user)+ ->tool(ListPostsTool::class, ['search' => 'marketing']);++ $response->assertOk()+ ->assertStructuredContent(function (AssertableJson $json) use ($matching) {+ $json->has('posts', 1, function (AssertableJson $post) use ($matching) {+ $post->where('id', $matching->id)->etc();+ })->etc();+ });+});++test('list posts search is case insensitive', function () {+ Post::factory()->create([+ 'workspace_id' => $this->workspace->id,+ 'user_id' => $this->user->id,+ 'content' => 'MARKETING CAMPAIGN',+ ]);+ Post::factory()->create([+ 'workspace_id' => $this->workspace->id,+ 'user_id' => $this->user->id,+ 'content' => 'Something else entirely',+ ]);++ $response = TryPostServer::actingAs($this->user)+ ->tool(ListPostsTool::class, ['search' => 'marketing']);++ $response->assertOk()+ ->assertStructuredContent(function (AssertableJson $json) {+ $json->has('posts', 1)->etc();+ });+});+test('get post returns PostResource shape', function () {$post = Post::factory()->create(['workspace_id' => $this->workspace->id,diff --git a/tests/Feature/WorkspaceLabelControllerTest.php b/tests/Feature/WorkspaceLabelControllerTest.phpindex 408a3a86b..c4ecde282 100644--- a/tests/Feature/WorkspaceLabelControllerTest.php+++ b/tests/Feature/WorkspaceLabelControllerTest.php@@ -166,6 +166,19 @@ test('labels index filters by search query', function () {);});+test('labels index search is case insensitive', function () {+ WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'IMPORTANT']);+ WorkspaceLabel::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'Urgent']);++ $response = $this->actingAs($this->user)->get(route('app.labels.index', ['search' => 'important']));++ $response->assertOk();+ $response->assertInertia(fn ($page) => $page+ ->has('labels.data', 1)+ ->where('filters.search', 'important')+ );+});+test('labels index returns all when no search query', function () {WorkspaceLabel::factory()->count(3)->create(['workspace_id' => $this->workspace->id]);diff --git a/tests/Feature/WorkspaceSignatureControllerTest.php b/tests/Feature/WorkspaceSignatureControllerTest.phpindex 7c9502c88..e47c06a03 100644--- a/tests/Feature/WorkspaceSignatureControllerTest.php+++ b/tests/Feature/WorkspaceSignatureControllerTest.php@@ -157,6 +157,19 @@ test('signatures index filters by search query', function () {);});+test('signatures index search is case insensitive', function () {+ WorkspaceSignature::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'MARKETING']);+ WorkspaceSignature::factory()->create(['workspace_id' => $this->workspace->id, 'name' => 'Travel']);++ $response = $this->actingAs($this->user)->get(route('app.signatures.index', ['search' => 'marketing']));++ $response->assertOk();+ $response->assertInertia(fn ($page) => $page+ ->has('signatures.data', 1)+ ->where('filters.search', 'marketing')+ );+});+test('signatures index returns all when no search query', function () {WorkspaceSignature::factory()->count(3)->create(['workspace_id' => $this->workspace->id]);