Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Ardent: Laravel 6 support #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ Route::post('register', function() {
'password_confirmation' => 'required|min:6'
);

$validator = Validator::make(Input::all(), $rules);
$validator = Validator::make(request()->all(), $rules);

if ($validator->passes()) {
User::create(array(
'name' => Input::get('name'),
'email' => Input::get('email'),
'password' => Hash::make(Input::get('password'))
'name' => request()->get('name'),
'email' => request()->get('email'),
'password' => Hash::make(request()->get('password'))
));

return Redirect::to('/')->with('message', 'Thanks for registering!');
Expand Down Expand Up @@ -321,9 +321,9 @@ Let's see it action. Consider this snippet of code:

```php
$user = new User;
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));
$user->name = request()->get('name');
$user->email = request()->get('email');
$user->password = Hash::make(request()->get('password'));
$user->save();
```

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"support": {
"issues": "https://github.com/laravelbook/ardent/issues"
},
"require": {
"illuminate/support": "~5.1",
"illuminate/database": "~5.1",
"illuminate/validation": "~5.1",
"illuminate/events": "~5.1",
"illuminate/hashing": "~5.1"
"require": {
"illuminate/support": ">5.1",
"illuminate/database": ">5.1",
"illuminate/validation": ">5.1",
"illuminate/events": ">5.1",
"illuminate/hashing": ">5.1"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 8 additions & 8 deletions src/Ardent/Ardent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Events\Dispatcher;
use Illuminate\Hashing\BcryptHasher;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -77,7 +77,7 @@ abstract class Ardent extends Model {
public static $throwOnFind = false;

/**
* If set to true, the object will automatically populate model attributes from Input::all()
* If set to true, the object will automatically populate model attributes from request()->all()
*
* @var bool
*/
Expand Down Expand Up @@ -423,7 +423,7 @@ public function belongsTo($related, $foreignKey = NULL, $otherKey = NULL, $relat
}

if (is_null($foreignKey)) {
$foreignKey = snake_case($relation).'_id';
$foreignKey = Str::snake($relation).'_id';
}

// Once we have the foreign key names, we'll just create a new Eloquent query
Expand Down Expand Up @@ -457,7 +457,7 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
$backtrace = debug_backtrace(false);
$caller = ($backtrace[1]['function'] == 'handleRelationalArray')? $backtrace[3] : $backtrace[1];

$name = snake_case($caller['function']);
$name = Str::snake($caller['function']);
}

// Next we will guess the type and ID if necessary. The type and IDs may also
Expand All @@ -481,7 +481,7 @@ public function getAttribute($key) {
$attr = parent::getAttribute($key);

if ($attr === null) {
$camelKey = camel_case($key);
$camelKey = Str::camel($key);
if (array_key_exists($camelKey, static::$relationsData)) {
$this->relations[$key] = $this->$camelKey()->getResults();
return $this->relations[$key];
Expand Down Expand Up @@ -572,7 +572,7 @@ public function validate(array $rules = array(), array $customMessages = array()
$customAttributes = (empty($customAttributes))? static::$customAttributes : $customAttributes;

if ($this->forceEntityHydrationFromInput || (empty($this->attributes) && $this->autoHydrateEntityFromInput)) {
$this->fill(Input::all());
$this->fill(request()->all());
}

$data = $this->getAttributes(); // the data under validation
Expand All @@ -591,8 +591,8 @@ public function validate(array $rules = array(), array $customMessages = array()
$this->validationErrors = $this->validator->messages();

// stash the input to the current session
if (!self::$external && Input::hasSession()) {
Input::flash();
if (!self::$external && request()->hasSession()) {
request()->flash();
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/Ardent/Facades/Ardent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php namespace LaravelArdent\Ardent\Facades;

use Illuminate\Support\Facades\Facade;

class Ardent extends Facade {

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'ardent'; }

}
45 changes: 45 additions & 0 deletions src/Ardent/Providers/ArdentServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php namespace LaravelArdent\Ardent\Providers;

use Illuminate\Support\ServiceProvider;
use LaravelArdent\Ardent\Ardent;

class ArdentServiceProvider extends ServiceProvider {

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('LaravelArdent/ardent');
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('ardent');
}

}