User: qixieyu Date: 15-7-3 Time: 下午8:41
Inheritance: extends Db
コード例 #1
0
ファイル: Bool.php プロジェクト: ajb/rfpez
 /**
  * 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);
     }
 }
コード例 #2
0
ファイル: BaseManager.php プロジェクト: iscnorena/report
 /**
  * @return boolean true
  * @throws ValidationException
  */
 public function save()
 {
     $this->isValid();
     $this->entity->fill($this->prepareData($this->data));
     $this->entity->save();
     return true;
 }
コード例 #3
0
ファイル: Model.php プロジェクト: assurrussa/grid-view-vue
 /**
  * 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;
 }
コード例 #4
0
ファイル: YCMS.php プロジェクト: ycms/framework
 /**
  * 格式化表单校验消息
  *
  * @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;
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: reith2004/domain
/**
 * 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);
}
コード例 #6
0
 /**
  * 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();
 }
コード例 #7
0
 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();
         }
     }
 }
コード例 #8
0
ファイル: Filer.php プロジェクト: LavaLite/framework
 /**
  * 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();
     }
 }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 /**
  * 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)]);
 }
コード例 #11
0
ファイル: Scan.php プロジェクト: p-tricky/CAEWeb
 public function save(array $options = array())
 {
     parent::save($options);
     $scanUser = $this->getScansUserById();
     $scanUser->updateTotal();
     $scanUser->updateMostRecentScan();
 }
コード例 #12
0
ファイル: Topic.php プロジェクト: 6174/phphub
 public static function boot()
 {
     parent::boot();
     static::created(function ($topic) {
         SiteStatus::newTopic();
     });
 }
コード例 #13
0
 /**
  * Deletes a blog post and all
  * the associated comments.
  *
  * @return bool
  */
 public function delete()
 {
     // Delete the comments
     $this->comments()->delete();
     // Delete the blog post
     return parent::delete();
 }
コード例 #14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('EmployeesTableSeeder');
     $this->call('TasksTableSeeder');
     $this->call('CategoriesTableSeeder');
 }
コード例 #15
0
 public static function boot()
 {
     parent::boot();
     if (!static::$logActivities) {
         return true;
     }
     // Attach to created event
     static::created(function ($model) {
         Activity::log(['contentId' => $model->id, 'contentType' => get_class($model), 'action' => 'Created', 'description' => 'Created ' . get_class($model)]);
     });
     static::deleted(function ($model) {
         Activity::log(['contentId' => $model->id, 'contentType' => get_class($model), 'action' => 'Deleted', 'description' => 'Deleted ' . get_class($model)]);
     });
     static::updating(function ($model) {
         $details = '';
         // Get changes in model
         foreach ($model->getDirty() as $attribute => $value) {
             $original = $model->getOriginal($attribute);
             $details .= "{$attribute}: from '{$original}' to '{$value}'\r\n";
         }
         // Do not log if there's no changes
         if (!empty($details)) {
             Activity::log(['contentId' => $model->id, 'contentType' => get_class($model), 'action' => 'Updated', 'description' => 'Updated ' . get_class($model), 'details' => trim($details)]);
         }
     });
 }
コード例 #16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('RangeCronJobsTableSeeder');
     $this->call('UserMgmtTablesSeeder');
     $this->call('AddTypesTableSeeder');
 }
コード例 #17
0
ファイル: DatabaseSeeder.php プロジェクト: elecom/skutools
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('RolesTableSeeder');
     $this->call('SedesTableSeeder');
     $this->call('UsuariosTableSeeder');
 }
コード例 #18
0
ファイル: DatabaseSeeder.php プロジェクト: dwbfox/pasteboard
 /**
  * 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";
     }
 }
コード例 #19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('InvoiceTableSeeder');
     $this->call('InvoiceItemTableSeeder');
     $this->call('BookTableSeeder');
 }
コード例 #20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('UsersTableSeeder');
     $this->call('PostsTableSeeder');
     $this->call('FavoritesTableSeeder');
 }
コード例 #21
0
ファイル: DatabaseSeeder.php プロジェクト: rituzy/iblog
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     //$this->call('UserTableSeeder');
     //$this->call('UserGroupSeeder');
     $this->call('PostCommentSeeder');
 }
コード例 #22
0
 public static function boot()
 {
     parent::boot();
     static::deleting(function ($photo) {
         $photo->galleries()->detach($photo->id);
         return true;
     });
     static::deleted(function ($photo) {
         unlink(public_path() . \Config::get('laravel-photogallery::upload_dir') . '/' . $photo->path);
         $destination = public_path() . \Config::get('laravel-photogallery::upload_dir') . "/";
         $formats = \Config::get('laravel-photogallery::formats');
         foreach ($formats as $name => $format) {
             unlink($destination . $name . '/' . $photo->path);
         }
     });
     static::created(function ($photo) {
         $destination = public_path() . \Config::get('laravel-photogallery::upload_dir') . "/";
         $orig = $destination . $photo->path;
         $img = \Image::make($orig);
         $formats = \Config::get('laravel-photogallery::formats');
         foreach ($formats as $name => $format) {
             $img->resize($format['w'], $format['h'], function ($constraint) {
                 $constraint->aspectRatio();
             });
             $img->save($destination . $name . '/' . $photo->path, $format['q']);
         }
     });
 }
コード例 #23
0
 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'));
 }
コード例 #24
0
ファイル: Eloquent.php プロジェクト: qxy735/YuYi-General
 /**
  * 设置 Model 类型对象
  *
  * @param Model $model
  */
 public function setModelObject(Model $model)
 {
     $config = $model->getConnection();
     self::$table = $config['tablename'];
     $this->setConfig($config);
     self::$model = $model;
 }
コード例 #25
0
ファイル: Presupuestos.php プロジェクト: elioth010/bg-dental
 public function newPivot(Eloquent $parent, array $attributes, $table, $exists)
 {
     if ($parent instanceof Tratamientos) {
         return new PresupuestoTratamiento($parent, $attributes, $table, $exists);
     }
     return parent::newPivot($parent, $attributes, $table, $exists);
 }
コード例 #26
0
ファイル: Model.php プロジェクト: leebivip/laravel_cmp
 /**
  * Listen for save event
  */
 protected static function boot()
 {
     parent::boot();
     static::saving(function ($model) {
         return $model->validate();
     });
 }
コード例 #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call(UserTableSeeder::class);
     $tbis->call(EventsTableSeeder::class);
     Eloquent::reguard();
 }
コード例 #28
0
ファイル: YearsTableSeeder.php プロジェクト: bluesky777/5myvc
 public function run()
 {
     Eloquent::unguard();
     DB::table('years')->delete();
     Year::create(['id' => 1, 'year' => 2015, 'nombre_colegio' => 'LICEO ADVENTISTA LIBERTAD', 'abrev_colegio' => 'LAL', 'nota_minima_aceptada' => 70, 'resolucion' => 'RESOLUCIÓN 2563 DE 2014', 'actual' => true, 'alumnos_can_see_notas' => true]);
     $this->command->info("Año 2014 y 2015 agregados.");
     /* OTRA FORMA ********************************************************************
     		// Abrimos el archivo donde tengo los municipios restantes de Colombia
     		// recorremos los registros y los ingresamos a la base de datos
     		$this->command->info("Leemos los csv para las cuidades colombianas faltantes...");
     
     		$csv = dirname(__FILE__) .'/SqlTables/CuidadesDeColombia.csv'; 
     		$file_handle = fopen($csv, "r");
     
     		while (!feof($file_handle)) {
     		    $line = fgetcsv($file_handle);
     
     		    if (empty($line)) {
     		        continue; // skip blank lines
     		    }
     
     		    $c = array();
     		    $c['nombre']		= $line[0];
     		    $c['pais_codigo']	= $line[1];
     		    $c['distrito']		= $line[2];
     		    $c['poblacion']		= $line[3];
     
     		    //$this->command->info( implode(",", $c));
     		    DB::table('ciudads')->insert($c);
     		}
     		fclose($file_handle);
     */
 }
コード例 #29
0
ファイル: User.php プロジェクト: mhger/fablife
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($user) {
         SocialProfile::destroy($user->socialProfiles->lists('id'));
     });
 }
コード例 #30
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('UserSeeder');
     // $this->call('TransportasiSeeder');
     // $this->call('PasanganSeeder');
 }