Share.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\models\goods;
  3. use app\common\models\BaseModel;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Validation\lValidator;
  6. /**
  7. * Created by PhpStorm.
  8. * Author: 芸众商城 www.yunzshop.com
  9. * Date: 2017/2/22
  10. * Time: 下午5:54
  11. */
  12. class Share extends BaseModel
  13. {
  14. public $table = 'yz_goods_share';
  15. //public $timestamps = true;
  16. public $attributes = [
  17. 'need_follow' => 1,
  18. ];
  19. /**
  20. * 不可填充字段.
  21. *
  22. * @var array
  23. */
  24. protected $guarded = ['updated_at', 'created_at'];
  25. /**
  26. * 自定义显示错误信息
  27. * @return array
  28. */
  29. public static function getGoodsShareInfo($goodsId)
  30. {
  31. $goodsShareInfo = self::where('goods_id', $goodsId)
  32. ->first();
  33. return $goodsShareInfo;
  34. }
  35. /**
  36. * 自定义字段名
  37. * 可使用
  38. * @return array
  39. */
  40. public function atributeNames()
  41. {
  42. return [
  43. // 'need_follow' => '强制关注',
  44. 'no_follow_message' => '未关注提示信息',
  45. 'follow_message' => '关注引导信息',
  46. 'share_title' => '分享标题',
  47. 'share_thumb' => '分享图片',
  48. 'share_desc' => '分享描述',
  49. ];
  50. }
  51. public function rules()
  52. {
  53. return [
  54. // 'need_follow' => 'required|digits_between:0,1',
  55. 'no_follow_message' => 'max:255',
  56. 'follow_message' => 'max:255',
  57. 'share_title' => 'max:50',
  58. 'share_thumb' => '',
  59. 'share_desc' => '',
  60. ];
  61. }
  62. }