示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create('pl_PL');
     foreach (range(1, 5) as $index) {
         DB::table('pages')->insert(['name' => $faker->name, 'short_description' => $faker->realText(rand(20, 20)), 'description' => $faker->realText(rand(20, 20)), 'seo' => Illuminate\Support\Str::slug($faker->name), 'public_date' => date($format = 'Y-m-d'), 'create_date' => date($format = 'Y-m-d')]);
     }
 }
 /**
  * Convert a value to studly caps case.
  *
  * @param  string  $value
  * @return string
  */
 function studly_case($value)
 {
     return Illuminate\Support\Str::studly($value);
 }
示例#3
0
|------------------------------------------------------------------
|Guest Routes
|--------------------------------------------------------------------
| Here defining Guest User's routes
|
|
*/
// seasrch
Route::POST('tickets/search/', function () {
    $keyword = Illuminate\Support\Str::lower(Input::get('auto'));
    $models = App\Model\Ticket\Tickets::where('ticket_number', '=', $keyword)->orderby('ticket_number')->take(10)->skip(0)->get();
    $count = count($models);
    return Illuminate\Support\Facades\Redirect::back()->with("contents", $models)->with("counts", $count);
});
Route::any('getdata', function () {
    $term = Illuminate\Support\Str::lower(Input::get('term'));
    $data = Illuminate\Support\Facades\DB::table("tickets")->distinct()->select('ticket_number')->where('ticket_number', 'LIKE', $term . '%')->groupBy('ticket_number')->take(10)->get();
    foreach ($data as $v) {
        return ['value' => $v->ticket_number];
    }
});
Route::get('getform', ['as' => 'guest.getform', 'uses' => 'Client\\helpdesk\\FormController@getForm']);
/* get the form for create a ticket by guest user */
Route::post('postform/{id}', 'Client\\helpdesk\\FormController@postForm');
/* post the AJAX form for create a ticket by guest user */
Route::post('postedform', 'Client\\helpdesk\\FormController@postedForm');
/* post the form to store the value */
Route::get('check', 'CheckController@getcheck');
//testing checkbox auto-populate
Route::post('postcheck/{id}', 'CheckController@postcheck');
Route::get('home', ['as' => 'home', 'uses' => 'Client\\helpdesk\\WelcomepageController@index']);
示例#4
0
 /**
  * Return an array of answers.
  *
  * @return array
  */
 public function answersExplodedArray()
 {
     $groupped = [];
     foreach ($this->answers->allWithMedicalCenters()->toArray() as $answer) {
         foreach ($answer as $key => $value) {
             $answer_id = $answer['id'];
             // If we find a nested array, ignore it
             if (is_array($answer[$key])) {
                 continue;
             }
             // When we are at medical_center_id, substitute it for its name and id
             if ($key === 'medical_center_id') {
                 $groupped['medical_center_id'][$answer_id] = $answer['medical_center']['id'];
                 $groupped['medical_center_email'][$answer_id] = $answer['medical_center']['email'];
                 $groupped['medical_center'][$answer_id] = $answer['medical_center']['name'];
                 continue;
             }
             // if (!is_array($value)) {
             //     $values = (!in_array($key, $this->dontExplodeValue)) ? explode(',', $value) : [$value];
             // }
             // Add it to the groupped array
             $group = array_filter(explode(',', $value));
             if (!in_array($key, $this->dontExplodeValue)) {
                 // if (count($group) > 1) {
                 foreach ($group as $val) {
                     // Ignore specific field
                     if (in_array($key, ['commentaires'])) {
                         continue;
                     }
                     $str = new \Illuminate\Support\Str();
                     $val = substr($str->slug($val), 0, 35);
                     $groupped[$key . '_' . $val][$answer_id] = 1;
                 }
             } else {
                 $groupped[$key][$answer_id] = $value;
             }
         }
     }
     return $groupped;
 }
 public function replaceName(&$stub, $name)
 {
     $str = new \Illuminate\Support\Str();
     $name = $str->snake(str_replace('Navigation', '', $name));
     $stub = str_replace('{{name}}', $name, $stub);
 }
<?php

/**
 * User Factory
 */
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10))];
});
$factory->defineAs(App\Models\User::class, 'activated', function (Faker\Generator $faker) use($factory) {
    $user = $factory->raw(App\Models\User::class);
    return array_merge($user, ['status' => UserStatus::ACTIVATED()]);
});
$factory->defineAs(App\Models\User::class, 'deactivated', function (Faker\Generator $faker) use($factory) {
    $user = $factory->raw(App\Models\User::class);
    return array_merge($user, ['status' => UserStatus::DEACTIVATED()]);
});
/**
 * Post Factory
 */
$factory->define(App\Models\Post::class, function (Faker\Generator $faker) {
    $sentence = $faker->sentence;
    return ['user_id' => 1, 'title' => $sentence, 'excerpt' => $sentence, 'body' => $faker->paragraphs(6, true), 'uri' => Illuminate\Support\Str::slug($sentence)];
});
$factory->defineAs(App\Models\Post::class, 'published', function (Faker\Generator $faker) use($factory) {
    $post = $factory->raw(App\Models\Post::class);
    return array_merge($post, ['status' => PostStatus::PUBLISHED()]);
});
$factory->defineAs(App\Models\Post::class, 'drafted', function (Faker\Generator $faker) use($factory) {
    $post = $factory->raw(App\Models\Post::class);
    return array_merge($post, ['status' => PostStatus::DRAFTED()]);
});
    $progress("Creating migrations table...");
    $repository->createRepository();
    $progress("done.\n");
}
$path = __DIR__ . '/../laravel/database/migrations';
$files = glob($path . '/*_*.php');
$files = array_map(function ($file) {
    return str_replace('.php', '', basename($file));
}, $files);
sort($files);
$ran = $repository->getRan();
$migrations = array_diff($files, $ran);
if (count($migrations) == 0) {
    $progress("Nothing to migrate.\n");
    return;
}
foreach ($migrations as $file) {
    require_once $path . '/' . $file . '.php';
}
$batch = $repository->getNextBatchNumber();
foreach ($migrations as $file) {
    $class = implode('_', array_slice(explode('_', $file), 4));
    $class = Illuminate\Support\Str::studly($class);
    $migration = new $class();
    $progress("Running {$class}::up() migration...");
    $migration->up();
    $progress("done.\n");
    $repository->log($file, $batch);
}
$progress("All migrations complete.\n");
unset($progress);
<?php

$factory->define(App\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(App\Subscription::class, function (Faker\Generator $faker) {
    return ['email' => $faker->email, 'key' => Illuminate\Support\Str::random(128), 'ip_address' => $faker->ipv4(), 'confirmed' => false, 'active' => false];
});