1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * Created by PhpStorm.
- * User: hp
- * Date: 2017/11/21
- * Time: 8:59
- */
- namespace App\Modules\Channel\Models;
- use DB;
- use Illuminate\Database\Eloquent\Model;
- class ChannelSellPlatforms extends Model
- {
- protected $table = 'channel_sell_platforms';
- protected $fillable = ['id', 'name', 'code', 'desc', 'bill_type', 'created_at', 'updated_at'];
- /**
- * 根据id查找
- * @param $id
- * @return mixed
- */
- static function getById($id)
- {
- return self::where('id', $id)->first();
- }
- /**
- * 根据名称查找
- * @param $name
- * @return mixed
- */
- static function getByName($name)
- {
- return self::where('name', $name)->first();
- }
- /**
- * 根据code查找
- * @param $code
- * @return mixed
- */
- static function getByCode($code)
- {
- return self::where('code', $code)->first();
- }
- /**
- * 添加记录
- * @param $data
- * @return mixed
- */
- static function addInfo($data)
- {
- return self::create($data);
- }
- /**
- * 获取列表
- * @return mixed
- */
- static function getList()
- {
- return self::paginate();
- }
- /**
- * 根据id更新
- * @param $id id
- * @param array $params
- * @return mixed
- */
- static function updateById($id, $params = [])
- {
- if ($params) {
- return self::where('id', $id)->update($params);
- }
- }
- }
|