Skip to content

Commit f906a0c

Browse files
authored
Merge pull request #645 from hhaccessibility/profile-route-changes
Profile route changes
2 parents 4faec3b + ed48617 commit f906a0c

24 files changed

Lines changed: 72 additions & 56 deletions

app/app/Country.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
class Country extends Model
1212
{
1313
protected $table = 'country';
14-
protected $fillable = ["name"
15-
];
14+
protected $fillable = ["name"];
1615
public $timestamps = false;
1716
}

app/app/DataSource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class DataSource extends Eloquent
7+
class DataSource extends Model
88
{
99
protected $fillable = [
1010
'name', 'description',
@@ -18,6 +18,6 @@ class DataSource extends Eloquent
1818
*/
1919
public function locations()
2020
{
21-
return $this->belongsToMany('App\Location');
21+
return $this->hasMany(Location::class, 'data_source_id');
2222
}
2323
}

app/app/Http/Controllers/HomeController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use App\LocationTag;
44
use App\BaseUser;
5+
use App\LocationSearchOption;
56
use DB;
67
use Illuminate\Routing\Controller;
78
use Illuminate\Http\Request;
@@ -21,7 +22,7 @@ public function index(Request $request)
2122
if (trim($address_value) === trim(BaseUser::getDefaultAddress())) {
2223
$address_value = '';
2324
}
24-
$location_search_options = DB::table('location_search_option')->get();
25+
$location_search_options = LocationSearchOption::query()->get();
2526
if (Input::has('keywords')) {
2627
$keywords = trim(Input::get('keywords'));
2728
BaseUser::setKeywords($keywords);

app/app/Http/Controllers/ProfileController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use App\Country;
66
use App\AnswerRepository;
77
use App\Region;
8-
use App\Http\Controllers\ProfilePhotoUploadController;
8+
use App\Http\Controllers\ProfilePhotoController;
99
use Illuminate\Http\Request;
1010
use Illuminate\Support\Facades\Validator;
1111
use Illuminate\Support\Facades\Input;
@@ -41,7 +41,7 @@ public static function getProfileView($validator = null)
4141
'address_default' => BaseUser::getDefaultAddress(),
4242
'countries' => $countries,
4343
'required_questions' => $required_questions,
44-
'has_profile_photo' => ProfilePhotoUploadController::hasProfilePhoto(),
44+
'has_profile_photo' => ProfilePhotoController::hasProfilePhoto(),
4545
'num_reviews' => count(AnswerRepository::getReviewedLocations()['location_ids']),
4646
'num_locations_added_by_me' => $num_locations_added_by_me,
4747
'is_internal_user' => BaseUser::isInternal(),

app/app/Http/Controllers/ProfilePhotoUploadController.php renamed to app/app/Http/Controllers/ProfilePhotoController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Support\Facades\Input;
77
use Illuminate\Support\Facades\Redirect;
88

9-
class ProfilePhotoUploadController extends Controller
9+
class ProfilePhotoController extends Controller
1010
{
1111

1212
public function index(Request $request)
@@ -26,12 +26,12 @@ private static function getUploadDirectory()
2626
private static function getProfilePhotoPath()
2727
{
2828
$user = BaseUser::getDbUser();
29-
return ProfilePhotoUploadController::getUploadDirectory() . 'user_' . $user->id . '.jpg';
29+
return ProfilePhotoController::getUploadDirectory() . 'user_' . $user->id . '.jpg';
3030
}
3131

3232
public static function hasProfilePhoto()
3333
{
34-
return file_exists(ProfilePhotoUploadController::getProfilePhotoPath());
34+
return file_exists(ProfilePhotoController::getProfilePhotoPath());
3535
}
3636

3737
/**
@@ -60,7 +60,7 @@ private static function getFileNameFromOriginalName(string $user_id, string $ori
6060
public function photo()
6161
{
6262
if (BaseUser::isSignedIn()) {
63-
$file_path = ProfilePhotoUploadController::getProfilePhotoPath();
63+
$file_path = ProfilePhotoController::getProfilePhotoPath();
6464
return response()->file($file_path);
6565
} else {
6666
return redirect()->intended('signin');
@@ -88,15 +88,15 @@ private static function getPhotoDimensionsFromUploadDimensions($width, $height)
8888

8989
public static function save($image)
9090
{
91-
$destinationPath = ProfilePhotoUploadController::getUploadDirectory();
91+
$destinationPath = ProfilePhotoController::getUploadDirectory();
9292

9393
$user = BaseUser::getDbUser();
9494

9595
$full_path = $destinationPath . 'user_' . $user->id . '.jpg';
9696

9797
$width = imagesx($image);
9898
$height = imagesy($image);
99-
$newDimensions = ProfilePhotoUploadController::getPhotoDimensionsFromUploadDimensions($width, $height);
99+
$newDimensions = ProfilePhotoController::getPhotoDimensionsFromUploadDimensions($width, $height);
100100

101101
// png images can be transparent and the transparent areas are defaulted to black.
102102
// We want the background to default to white.
@@ -129,15 +129,15 @@ public function post(Request $request)
129129
$content = file_get_contents($temp_filename);
130130
$new_image = imagecreatefromstring($content);
131131

132-
return ProfilePhotoUploadController::save($new_image);
132+
return ProfilePhotoController::save($new_image);
133133
} else {
134134
return redirect()->intended('signin');
135135
}
136136
}
137137

138138
public function delete()
139139
{
140-
$file = ProfilePhotoUploadController::getProfilePhotoPath();
140+
$file = ProfilePhotoController::getProfilePhotoPath();
141141
if (!unlink($file)) {
142142
echo ("Error deleting $file");
143143
} else {
@@ -148,12 +148,12 @@ public function delete()
148148
// Rotate Profile Photo
149149
public function rotate()
150150
{
151-
$current_photo = ProfilePhotoUploadController::getProfilePhotoPath();
151+
$current_photo = ProfilePhotoController::getProfilePhotoPath();
152152

153153
$content = file_get_contents($current_photo);
154154
$image = imagecreatefromstring($content);
155155

156156
$new_image = imagerotate($image, -90, 0);
157-
return ProfilePhotoUploadController::save($new_image);
157+
return ProfilePhotoController::save($new_image);
158158
}
159159
}

app/app/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use Webpatser\Uuid\Uuid;
77

8-
class Image extends Eloquent
8+
class Image extends Model
99
{
1010
protected $fillable = [
1111
'id', 'location_id', 'raw_data',

app/app/Location.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use DB;
77
use Webpatser\Uuid\Uuid;
88

9-
class Location extends Eloquent
9+
class Location extends Model
1010
{
1111
protected $fillable = [
1212
'name', 'phone_number', 'longitude', 'latitude', 'owner_user_id',
1313
'data_source_id', 'universal_rating', 'creator_user_id', 'ratings_cache'
1414
];
15+
1516
public $timestamps = false;
1617

1718
protected $casts = [
1819
'ratings_cache' => 'array'
1920
];
21+
2022
protected $table = 'location';
2123
/**
2224
* Indicates if the IDs are auto-incrementing.
@@ -57,7 +59,7 @@ public function personalizedRatings()
5759

5860
public function comments()
5961
{
60-
return $this->hasMany('App\ReviewComment');
62+
return $this->hasMany(ReviewComment::class);
6163
}
6264

6365
public function locationGroup()

app/app/LocationGroup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66

7-
class LocationGroup extends Eloquent
7+
class LocationGroup extends Model
88
{
99
protected $fillable = [
1010
'name',

app/app/LocationLocationTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App;
44

5-
use Eloquent;
5+
use Illuminate\Database\Eloquent\Model;
66
use Webpatser\Uuid\Uuid;
77

8-
class LocationLocationTag extends Eloquent
8+
class LocationLocationTag extends Model
99
{
1010
protected $fillable = [
1111
'location_id', 'location_tag_id',

app/app/LocationSearchOption.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class LocationSearchOption extends Model
8+
{
9+
protected $fillable = [
10+
'content'
11+
];
12+
13+
protected $table = 'location_search_option';
14+
}

0 commit comments

Comments
 (0)