-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Search, errors and user validation
- Loading branch information
RichardHpa
committed
Nov 27, 2017
1 parent
b2e3ff0
commit 384a009
Showing
18 changed files
with
189 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\BlogPosts; | ||
|
||
class SearchController extends Controller | ||
{ | ||
public function index(){ | ||
if(isset($_GET['q'])){ | ||
$searchTerm = $_GET['q']; | ||
//manipulate the variable if needed | ||
} else{ | ||
$serachTerm = ""; | ||
} | ||
|
||
$searchResults = BlogPosts::where('post_title', 'LIKE', '%'.$searchTerm.'%') | ||
->orWhere('post_description', 'LIKE', '%'.$searchTerm.'%') | ||
->get(); | ||
|
||
return view('search.index', compact('searchResults')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
database/migrations/2017_11_27_202520_add_userid_to_blogposts.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class AddUseridToBlogposts extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('blog_posts', function (Blueprint $table) { | ||
$table->integer('user_id')->unsigned()->after('image_name'); | ||
$table->foreign('user_id')->references('id')->on('users'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('blog_posts', function (Blueprint $table) { | ||
$table->dropForeign(['user_id']); | ||
$table->dropColumn('user_id'); | ||
}); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@extends('layouts.master') | ||
|
||
@section('title', '401 Page not Found') | ||
@section('description', '401 Page not found') | ||
|
||
@section('styles') | ||
|
||
@endsection | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="jumbotron jumbotron-fluid"> | ||
<h1>Error 401</h1> | ||
<p>You must have the right privilages to view this page.</p> | ||
</div> | ||
</div> | ||
@endsection | ||
|
||
@section('scripts') | ||
|
||
@endsection | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@extends('layouts.master') | ||
|
||
@section('title', '404 Page not Found') | ||
@section('description', '404 Page not found') | ||
|
||
@section('styles') | ||
|
||
@endsection | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="jumbotron jumbotron-fluid"> | ||
<h1>404 Page not found</h1> | ||
<p>The page you are looking for is not found, please try again.</p> | ||
</div> | ||
</div> | ||
@endsection | ||
|
||
@section('scripts') | ||
|
||
@endsection | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@extends('layouts.master') | ||
|
||
@section('title', 'Serach results') | ||
@section('description', 'List of Search Results') | ||
|
||
@section('styles') | ||
|
||
@endsection | ||
|
||
@section('content') | ||
<div class="container"> | ||
<h1>Search Results for: </h1> | ||
<hr> | ||
@if($searchResults) | ||
@foreach($searchResults as $result) | ||
<div class="col-xs-12"> | ||
<h3>{{$result->post_title}}</h3> | ||
<p>{{$result->post_description}}</p> | ||
<a href="{{ route('blog.show', $result->id)}}">go to post</a> | ||
</div> | ||
@endforeach | ||
@else | ||
<p>There was no results for your query</p> | ||
@endif | ||
</div> | ||
@endsection | ||
|
||
@section('scripts') | ||
|
||
@endsection | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters