Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. public function index(Request $request)
  2. {
  3.  
  4. if ($request) {
  5. $query = trim($request->get('searchText'));
  6.  
  7.  
  8. $articulos = DB::table('articulo as a')
  9. ->join('categoria as c', 'a.idcategoria', '=', 'c.idcategoria')
  10. ->select('a.idarticulo', 'a.nombre', 'a.codigo', 'a.stock', 'c.nombre as categoria', 'a.descripcion', 'a.imagen', 'a.estado')
  11. ->where('a.nombre', 'LIKE', '%' . $query . '%')
  12. ->orwhere('a.codigo', 'LIKE', '%' . $query . '%')
  13. ->orderBy('a.idarticulo', 'desc')
  14. ->union(->select('ar.idarticulo', 'ar.nombre', 'ar.codigo', 'ar.stock', 'ca.nombre as categoria', 'ar.descripcion', 'ar.imagen', 'ar.estado')
  15. ->where('ar.nombre', 'LIKE', '%' . $query . '%')
  16. ->orwhere('ar.codigo', 'LIKE', '%' . $query . '%')
  17. ->orderBy('ar.idarticulo', 'desc'))
  18.  
  19. $articulo2 = DB::connection('sqlsrv') and DB::table('articulo as ar')
  20. ->join('categoria as ca', 'ar.idcategoria', '=', 'ca.idcategoria')
  21. ->select('ar.idarticulo', 'ar.nombre', 'ar.codigo', 'ar.stock', 'ca.nombre as categoria', 'ar.descripcion', 'ar.imagen', 'ar.estado')
  22. ->where('ar.nombre', 'LIKE', '%' . $query . '%')
  23. ->orwhere('ar.codigo', 'LIKE', '%' . $query . '%')
  24. ->orderBy('ar.idarticulo', 'desc')
  25. ->paginate(7);
  26.  
  27. return view('almacen.articulo.index', ["articulos" => $articulos, "searchText" => $query]);
  28.  
  29. }
  30.  
  31. }
  32.  
  33. class Articulo extends Model
  34.  
  35. protected $connection = 'mysql';
  36. protected $table = 'articulo';
  37. protected $primaryKey = 'idarticulo';
  38.  
  39. public $timestamps = false;
  40.  
  41. protected $fillable = [
  42. 'idcategoria',
  43. 'codigo',
  44. 'nombre',
  45. 'stock',
  46. 'descripcion',
  47. 'imagen',
  48. 'estado',
  49. ];
  50.  
  51. protected $guarded = [
  52.  
  53. ];}
  54.  
  55. DB_CONNECTION=sqlsrv
  56. DB_HOST=127.0.0.1
  57. DB_PORT=1433
  58. DB_DATABASE=dbventas
  59. DB_USERNAME=Angelo
  60. DB_PASSWORD="Ad041095"
  61.  
  62. DB_CONNECTION2=mysql
  63. DB_HOST2=127.0.0.1
  64. DB_PORT2=3306
  65. DB_DATABASE2=dbventaslaravel
  66. DB_USERNAME2=root
  67. DB_PASSWORD2=
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement