Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

day 18

  • Loading branch information...
commit 088bea20b375dc1964b4eb35a67d638f6acda07d 1 parent edfa557
@typester authored
View
16 lib/Jobeet/Controller/Search.pm
@@ -0,0 +1,16 @@
+package Jobeet::Controller::Search;
+use Ark 'Controller';
+
+use Jobeet::Models;
+
+sub index :Path {
+ my ($self, $c) = @_;
+
+ my $query = $c->req->param('q')
+ or $c->detach('/default');
+
+ $c->stash->{jobs} = models('Schema::Job')->search_fulltext($query);
+}
+
+1;
+
View
14 lib/Jobeet/Schema/ResultSet/Job.pm
@@ -34,6 +34,20 @@ sub latest_post {
}
+sub search_fulltext {
+ my ($self, $word) = @_;
+
+ my $r = $self->search(
+ {
+ is_activated => 1,
+ -or => [
+ { description => { -like => "%${word}%", } },
+ { how_to_apply => { -like => "%${word}%", } },
+ ]
+ },
+ { order_by => { -desc => 'created_at' }, rows => 20 }
+ );
+}
1;
View
4 root/common/base.mt
@@ -27,8 +27,8 @@
<div class="search">
<h2>Ask for a job</h2>
- <form action="" method="get">
- <input type="text" name="keywords"
+ <form action="<?= $c->uri_for('/search') ?>" method="get">
+ <input type="text" name="q"
id="search_keywords" />
<input type="submit" value="search" />
<div class="help">
View
11 root/search/index.mt
@@ -0,0 +1,11 @@
+? extends 'common/jobs_base';
+
+? block content => sub {
+
+<div id="jobs">
+?= include('job/partial_jobs', $c->stash->{jobs}->all );
+</div>
+
+? } # endblock content
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.