PHPackages                             cortex/foundation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. cortex/foundation

AbandonedArchivedCortex-module[Framework](/categories/framework)

cortex/foundation
=================

The core foundation of Rinvex Cortex modular application architecture.

v8.3.6(1y ago)78.2k519MITPHPPHP ^8.1.0

Since Mar 14Pushed 1y ago3 watchersCompare

[ Source](https://github.com/rinvex/cortex-foundation-classic)[ Packagist](https://packagist.org/packages/cortex/foundation)[ Docs](https://rinvex.com)[ RSS](/packages/cortex-foundation/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (54)Versions (162)Used By (19)

Cortex Foundation
=================

[](#cortex-foundation)

The core foundation of **Rinvex Cortex** modular application architecture.

[![Packagist](https://camo.githubusercontent.com/968d73d9bd5e41f6ae394d88c41dc12c2052c3f50fe2027cf75ce3683c0ee6be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f727465782f666f756e646174696f6e2e7376673f6c6162656c3d5061636b6167697374267374796c653d666c61742d737175617265)](https://packagist.org/packages/cortex/foundation)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5ffca6e81780695bb339543966481ed6a75685aa0ea379df5d05ecb0976c05d6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72696e7665782f636f727465782d666f756e646174696f6e2e7376673f6c6162656c3d5363727574696e697a6572267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rinvex/cortex-foundation/)[![Travis](https://camo.githubusercontent.com/f9681f8430d1dbd966251b18f20c74fc09df09bb469e83384f5342cc73d6f5d2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72696e7665782f636f727465782d666f756e646174696f6e2e7376673f6c6162656c3d5472617669734349267374796c653d666c61742d737175617265)](https://travis-ci.org/rinvex/cortex-foundation)[![StyleCI](https://camo.githubusercontent.com/2c54a43103e2e843ee3721be97285f942dbb5cb4acbbdf1af251d4dd6146304d/68747470733a2f2f7374796c6563692e696f2f7265706f732f37373734363339302f736869656c64)](https://styleci.io/repos/77746390)[![License](https://camo.githubusercontent.com/082788f2e6272219fc1344a18bb0c4fd77ede8bbaa587673c5fc3b431269044b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f727465782f666f756e646174696f6e2e7376673f6c6162656c3d4c6963656e7365267374796c653d666c61742d737175617265)](https://github.com/rinvex/cortex-foundation/blob/develop/LICENSE)

Installation and Usage
----------------------

[](#installation-and-usage)

This package should **NOT** be installed individually, it's required by [`rinvex/cortex`](https://github.com/rinvex/cortex) and requires a new laravel application instance with special architecture satisfied with **Rinvex Cortex**.

This package still not yet documented, but you can use it on your own responsibility.

To be documented soon..!

### Support Helpers

[](#support-helpers)

#### `intend()`

[](#intend)

The `intend` method returns redirect response:

```
intend([
    'route' => 'route.name.here',
    'withErrors' => ['error.message.id' => 'A custom error message'],
]);
```

> **Note:** this helper accepts `redirect` methods as it's input keys, such as `withErrors`, `with`, `back`, and `route` ..etc

### unique\_with Validator Rule: Usage

[](#unique_with-validator-rule-usage)

Use it like any `Validator` rule:

```
$rules = [
    '' => 'unique_with:,[,,...,]',
];
```

See the [Validation documentation](http://laravel.com/docs/validation) of Laravel.

#### Specify different column names in the database

[](#specify-different-column-names-in-the-database)

If your input field names are different from the corresponding database columns, you can specify the column names explicitly.

E.g. your input contains a field 'last\_name', but the column in your database is called 'sur\_name':

```
$rules = [
    'first_name' => 'unique_with:users, middle_name, last_name = sur_name',
];
```

#### Ignore existing row (useful when updating)

[](#ignore-existing-row-useful-when-updating)

You can also specify a row id to ignore (useful to solve unique constraint when updating)

This will ignore row with id 2:

```
$rules = [
    'first_name' => 'required|unique_with:users,last_name,2',
    'last_name' => 'required',
];
```

To specify a custom column name for the id, pass it like:

```
$rules = [
    'first_name' => 'required|unique_with:users,last_name,2 = custom_id_column',
    'last_name' => 'required',
];
```

If your id is not numeric, you can tell the validator:

```
$rules = [
    'first_name' => 'required|unique_with:users,last_name,ignore:abc123',
    'last_name' => 'required',
];
```

#### Add additional clauses (e.g. when using soft deletes)

[](#add-additional-clauses-eg-when-using-soft-deletes)

You can also set additional clauses. For example, if your model uses soft deleting then you can use the following code to select all existing rows but marked as deleted

```
$rules = [
    'first_name' => 'required|unique_with:users,last_name,deleted_at,2 = custom_id_column',
    'last_name' => 'required',
];
```

*Soft delete caveat:*

In Laravel 5 (tested on 5.5), if the validation is performed in form request class, field deleted\_at is skipped, because it's not send in request. To solve this problem, add 'deleted\_at' =&gt; null to Your validation parameters in request class., e.g.:

```
protected function validationData()
{
    return array_merge($this->request->all(), [
        'deleted_at' => null
    ]);
}
```

#### Specify specific database connection to use

[](#specify-specific-database-connection-to-use)

If we have a connection named `some-database`, we can enforce this connection (rather than the default) like this:

```
$rules = [
    'first_name' => 'unique_with:some-database.users, middle_name, last_name',
];
```

E.g. pretend you have a `users` table in your database plus `User` model like this:

```
