Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
d6bb8da5
Commit
d6bb8da5
authored
Jun 08, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scout search
parent
926dc40b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
README.md
README.md
+24
-0
CartController.php
src/controllers/CartController.php
+14
-0
ProductShop.php
src/models/ProductShop.php
+3
-0
routes.php
src/routes.php
+1
-0
No files found.
README.md
View file @
d6bb8da5
...
...
@@ -72,6 +72,30 @@ SECRET_PAYPAL=secret id
PAYPAL_MODE=sandbox
```
-
for the search
```
composer require laravel/scout
composer require algolia/algoliasearch-client-php
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
```
-
env vars
```
ALGOLIA_APP_ID=YourApplicationID
ALGOLIA_SECRET=YourAdminAPIKey
ALGOLIA_SEARCH=YourSearchOnlyAPIKey
SCOUT_QUEUE=true
```
-
run
```
php artisan scout:import 'Onestartup\Shop\Model\ProductShop'
```
src/controllers/CartController.php
View file @
d6bb8da5
...
...
@@ -858,4 +858,18 @@ public function shipping()
return
$data
;
}
public
function
search
(
Request
$request
)
{
$error
=
[
'error'
=>
'Sin resultados, ingrese otros campos para la búsqueda.'
];
if
(
$request
->
has
(
'text'
))
{
$products
=
Product
::
search
(
$request
->
get
(
'text'
))
->
get
();
return
$products
->
count
()
?
$products
:
$error
;
}
return
$error
;
}
}
src/models/ProductShop.php
View file @
d6bb8da5
...
...
@@ -3,9 +3,12 @@
namespace
Onestartup\Shop\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Laravel\Scout\Searchable
;
class
ProductShop
extends
Model
{
use
Searchable
;
protected
$table
=
'products_shop'
;
protected
$fillable
=
[
'name'
,
...
...
src/routes.php
View file @
d6bb8da5
...
...
@@ -110,4 +110,5 @@ Route::group(['middleware' => ['web']], function(){
Route
::
get
(
'cart/testmail'
,
'Onestartup\Shop\Controller\CartController@testmail'
)
->
name
(
'cart.testmail'
);
Route
::
get
(
'get/coupon'
,
'Onestartup\Shop\Controller\CartController@discount'
)
->
name
(
'cart.discount'
);
Route
::
get
(
'/search'
,
'Onestartup\Shop\Controller\CartController@search'
)
->
name
(
'api.search'
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment