当前位置: 首页>>代码示例>>PHP>>正文


PHP Eloquent类代码示例

本文整理汇总了PHP中Eloquent的典型用法代码示例。如果您正苦于以下问题:PHP Eloquent类的具体用法?PHP Eloquent怎么用?PHP Eloquent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Eloquent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterQuery

 /**
  * Filters a query object
  *
  * @param Query		$query
  * @param Eloquent	$model
  *
  * @return void
  */
 public function filterQuery(&$query, $model)
 {
     //if the field is
     if ($this->value !== '') {
         $query->where($model->table() . '.' . $this->field, '=', $this->value);
     }
 }
开发者ID:ajb,项目名称:rfpez,代码行数:15,代码来源:Bool.php

示例2: hasColumn

 /**
  * Check if model's table has column
  *
  * @param \Eloquent $model
  * @param string $column
  * @return bool
  */
 public static function hasColumn($model, $column)
 {
     $table = $model->getTable();
     $columns = \Cache::remember('amigridview.columns.' . $table, 60, function () use($table) {
         return \Schema::getColumnListing($table);
     });
     return array_search($column, $columns) !== false;
 }
开发者ID:assurrussa,项目名称:grid-view-vue,代码行数:15,代码来源:Model.php

示例3: format_message

 /**
  * 格式化表单校验消息
  *
  * @param  array $messages 未格式化之前数组
  * @return string 格式化之后字符串
  */
 public static function format_message(\Eloquent $messages)
 {
     $reason = ' ';
     foreach ($messages->all('<span class="text_error">:message</span>') as $message) {
         $reason .= $message . ' ';
     }
     return $reason;
 }
开发者ID:ycms,项目名称:framework,代码行数:14,代码来源:YCMS.php

示例4: to_array

/**
 * Transform Eloquent models to a JSON object.
 *
 * @param  Eloquent|array  $models
 * @return object
 */
function to_array($models)
{
    if ($models instanceof Laravel\Database\Eloquent) {
        return $models->to_array();
    }
    return array_map(function ($m) {
        return $m->to_array();
    }, $models);
}
开发者ID:reith2004,项目名称:domain,代码行数:15,代码来源:helpers.php

示例5: __construct

 /**
  * EloquentManager constructor.
  *
  * @param Builder|\Eloquent $model
  * @param Request $request
  */
 public function __construct($model, Request $request)
 {
     $this->response = new DataTable();
     $this->query = $model instanceof Builder ? $model : $model->getQuery();
     $this->request = $request;
     //        $this->columns    = $this->query->columns;
     $this->connection = $model->getConnection();
     $this->prefix = $this->connection->getTablePrefix();
     $this->database = $this->connection->getDriverName();
 }
开发者ID:maurob45,项目名称:eloquentdatatables,代码行数:16,代码来源:EloquentManager.php

示例6: validateOwnership

 protected function validateOwnership(Eloquent $model)
 {
     // Validate correct resource
     if ($model_id = Request::segment(2)) {
         $count = $model->where('id', $model_id)->where('user_id', Auth::id())->count();
         if ($count === 0) {
             return $this->respondNotFound();
         }
     }
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:10,代码来源:BaseController.php

示例7: upload

 /**
  * Upload files and save to the table.
  *
  * @param Eloquent $model
  *
  * @return null
  */
 public function upload($model)
 {
     if (empty($model->uploads)) {
         return;
     }
     if (isset($model->uploads['single'])) {
         $model->uploadSingle();
     }
     if (isset($model->uploads['multiple'])) {
         $model->uploadMultiple();
     }
 }
开发者ID:LavaLite,项目名称:framework,代码行数:19,代码来源:Filer.php

示例8: validate

 public function validate(\Eloquent $model)
 {
     $additional_data = $this->getAdditionalData();
     $this->validator->setData(array_merge($model->getAttributes(), is_array($additional_data) ? $additional_data : array()));
     $this->setConditionalRules($model);
     if ($this->validator->fails()) {
         //Here we set any validation error responses to the error field on the model.
         $model->setAttribute('errors', $this->validator->errors());
         return $model;
     } else {
         return $model;
     }
 }
开发者ID:AlexCW,项目名称:LaravelUserApp,代码行数:13,代码来源:ValidationObserver.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::Create();
     $name = $faker->name;
     Eloquent::unguard();
     Writers::create(['name' => $name, 'bio' => 'This is just a sample Writer. There is nothing to say here!', 'image' => '/images/writers/SampleWriter.jpg', 'slug' => str_replace(' ', '-', $name)]);
 }
开发者ID:skinuxgeek,项目名称:NewsWise,代码行数:12,代码来源:WritersTableSeeder.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('EmployeesTableSeeder');
     $this->call('TasksTableSeeder');
     $this->call('CategoriesTableSeeder');
 }
开发者ID:gerry411,项目名称:MatasTasklist,代码行数:12,代码来源:DatabaseSeeder.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('tags')->truncate();
     //DB::table('pastes')->truncate();
     $faker = Faker\Factory::create();
     $paste_count = 10;
     $tags = array('php', 'javascript', 'ruby', 'js', 'cpp', 'c++', 'c#', 'go', 'html', 'css');
     for ($i = 0; $i < $paste_count; $i++) {
         $tags_per_paste = rand(1, 3);
         // Generate the paste
         $examplePaste = new Paste();
         $examplePaste->paste = $faker->paragraph;
         $examplePaste->title = $faker->realText(46);
         $examplePaste->expire = $faker->dateTime($max = 'now');
         $examplePaste->token = Str::random(40);
         $examplePaste->private = rand(0, 1);
         $examplePaste->delete_token = Str::random(40);
         $examplePaste->save();
         // Attach some tags to the new paste
         for ($i = 0; $i < $tags_per_paste; ++$i) {
             $exampleTag = new Tag();
             $exampleTag->tag = $tags[rand(0, sizeof($tags) - 1)];
             $exampleTag->paste_id = $examplePaste->id;
             $examplePaste->tags()->save($exampleTag);
         }
         print "Seeded paste with ID of " . $examplePaste->id . "\n";
     }
 }
开发者ID:dwbfox,项目名称:pasteboard,代码行数:34,代码来源:DatabaseSeeder.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     //$this->call('UserTableSeeder');
     //$this->call('UserGroupSeeder');
     $this->call('PostCommentSeeder');
 }
开发者ID:rituzy,项目名称:iblog,代码行数:12,代码来源:DatabaseSeeder.php

示例13: run

 public function run()
 {
     Eloquent::unguard();
     // DB::table('packages')->delete();
     $currentDate = date('Y-m-d');
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 5 days')), 'booking_time' => '01:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 5 days')), 'booking_time' => '23:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 10 days')), 'booking_time' => '13:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 10 days')), 'booking_time' => '14:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 11 days')), 'booking_time' => '13:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 11 days')), 'booking_time' => '16:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 12 days')), 'booking_time' => '10:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 12 days')), 'booking_time' => '14:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 13 days')), 'booking_time' => '16:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 13 days')), 'booking_time' => '17:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 14 days')), 'booking_time' => '13:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 14 days')), 'booking_time' => '11:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 15 days')), 'booking_time' => '12:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 15 days')), 'booking_time' => '13:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 16 days')), 'booking_time' => '16:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 16 days')), 'booking_time' => '19:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 17 days')), 'booking_time' => '13:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 17 days')), 'booking_time' => '14:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 17 days')), 'booking_time' => '15:00'));
     BookingTimes::create(array('booking_date' => date('Y-m-d', strtotime($currentDate . ' + 17 days')), 'booking_time' => '16:00'));
 }
开发者ID:RetinaInc,项目名称:booking-app,代码行数:26,代码来源:BookingTimesTableSeeder.php

示例14: save

 /**
  * @return boolean true
  * @throws ValidationException
  */
 public function save()
 {
     $this->isValid();
     $this->entity->fill($this->prepareData($this->data));
     $this->entity->save();
     return true;
 }
开发者ID:iscnorena,项目名称:report,代码行数:11,代码来源:BaseManager.php

示例15: save

 public function save(array $options = array())
 {
     parent::save($options);
     $scanUser = $this->getScansUserById();
     $scanUser->updateTotal();
     $scanUser->updateMostRecentScan();
 }
开发者ID:p-tricky,项目名称:CAEWeb,代码行数:7,代码来源:Scan.php


注:本文中的Eloquent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。