Skip to content

Commit

Permalink
Merge branch 'fix_some_bugs'
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHelalAhmed committed Sep 4, 2021
2 parents 5098433 + 99abebc commit 9d5e730
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
9 changes: 3 additions & 6 deletions app/Http/Requests/StoreChannelRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,16 @@ public function prepareForValidation()
$this->merge(['user_id' => auth()->id()]);
}

private function getChannelIdFromLink(string $url): string
private function getChannelIdFromLink(string $url): ?string
{
$parsed = parse_url(rtrim($url, '/'));
if (isset($parsed['path']) && preg_match('/^\/channel\/(([^\/])+?)$/', $parsed['path'], $matches)) {
return $matches[1];
}
return (new GettingChannelIdByLinkService)->execute($url);
}

public function messages()
{
return [
'remote_identifier.unique' => 'Channel already exists'
'remote_identifier.unique' => 'Channel already exists!',
'remote_identifier.required' => 'The link is wrong!'
];
}
}
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=c5fe426fc006be187d57",
"/js/app.js": "/js/app.js?id=4c465d3b6a260335f189",
"/css/app.css": "/css/app.css?id=6cc2e88e64301f36a09f"
}
9 changes: 7 additions & 2 deletions resources/js/Pages/Channels/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
id="link" type="url" name="link" placeholder="Channel link">
<div v-if="errors.link" class="text-red-600">{{ errors.link }}</div>
<div v-if="errors.remote_identifier" class="text-red-600">{{ errors.remote_identifier }}</div>
<div v-if="errors.remote_identifier" class="text-red-600">{{
errors.remote_identifier
}}
</div>

</div>
<div class="flex items-center justify-between">
Expand Down Expand Up @@ -79,7 +82,9 @@ export default defineComponent({
})
function submit() {
Inertia.post('/channels', form)
Inertia.post('/channels', form);
form.name = null;
form.link = null;
}
return {form, submit}
Expand Down

0 comments on commit 9d5e730

Please sign in to comment.