PHP code example of cortex / foundation
1. Go to this page and download the library: Download cortex/foundation library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cortex / foundation example snippets
intend([
'route' => 'route.name.here',
'withErrors' => ['error.message.id' => 'A custom error message'],
]);
$rules = [
'<field1>' => 'unique_with:<table>,<field2>[,<field3>,...,<ignore_rowid>]',
];
$rules = [
'first_name' => 'unique_with:users, middle_name, last_name = sur_name',
];
$rules = [
'first_name' => '];
$rules = [
'first_name' => '];
$rules = [
'first_name' => '];
$rules = [
'first_name' => '];
protected function validationData()
{
return array_merge($this->request->all(), [
'deleted_at' => null
]);
}
$rules = [
'first_name' => 'unique_with:some-database.users, middle_name, last_name',
];
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('first_name');
$table->string('last_name');
$table->unique(['first_name', 'last_name']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
class User extends Eloquent { }
Route::post('test', function() {
$rules = [
'first_name' => 'ake(Input::all(), $rules);
if($validator->fails()) {
return Redirect::back()->withErrors($validator);
}
$user = new User;
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->save();
return Redirect::route('home')->with('success', 'User created!');
});