Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.47 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gintautas
  5. * Date: 10/9/2014
  6. * Time: 11:44 AM
  7. */
  8.  
  9. class JobOffer extends Eloquent{
  10. protected $table='new_job_offer';
  11. //For search jobs in index
  12. public static function search($category, $location, $keyword)
  13. {
  14. if($keyword == ""){
  15. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name')
  16. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  17. ->where('new_job_offer.job_category', '=', $category)
  18. ->where('new_job_offer.location_region', '=', $location)
  19. ->orderBy('new_job_offer.created_at')
  20. ->paginate(10);
  21.  
  22.  
  23. }else{
  24.  
  25. $match = "MATCH( `job_description`,`job_title`) AGAINST (?)";
  26.  
  27. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name')
  28. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  29. ->where('new_job_offer.job_category', '=', $category)
  30. ->where('new_job_offer.location_region', '=', $location)
  31. ->whereRaw($match, array($keyword))
  32. ->orderBy('new_job_offer.created_at')
  33. ->paginate(10);
  34.  
  35. }
  36. return $query;
  37.  
  38. }
  39.  
  40. //For search jobs in worker menu
  41. public static function searchJobsInWorker($category, $location, $keyword)
  42. {
  43. $worker_id = Session::get('worker_id');
  44. if($keyword == ""){
  45. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name', 'applied_jobs.offer_id' )
  46. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  47. ->leftJoin('applied_jobs', function($leftJoin)use($worker_id)
  48. {
  49. $leftJoin->on('applied_jobs.offer_id', '=', 'new_job_offer.id');
  50. $leftJoin->on(DB::raw('applied_jobs.worker_id'), DB::raw('='),DB::raw("'".$worker_id."'"));
  51. })
  52. ->where('new_job_offer.job_category', '=', $category)
  53. ->where('new_job_offer.location_region', '=', $location)
  54. ->orderBy('new_job_offer.created_at')
  55. ->paginate(10);
  56.  
  57.  
  58. }else{
  59.  
  60. $match = "MATCH( `job_description`,`job_title`) AGAINST (?)";
  61.  
  62. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name')
  63. ->leftJoin('applied_jobs', function($leftJoin)use($worker_id)
  64. {
  65. $leftJoin->on('applied_jobs.offer_id', '=', 'new_job_offer.id');
  66. $leftJoin->on(DB::raw('applied_jobs.worker_id'), DB::raw('='),DB::raw("'".$worker_id."'"));
  67. })
  68. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  69. ->where('new_job_offer.job_category', '=', $category)
  70. ->where('new_job_offer.location_region', '=', $location)
  71. ->whereRaw($match, array($keyword))
  72. ->orderBy('new_job_offer.created_at')
  73. ->paginate(10);
  74.  
  75. }
  76.  
  77. Log::info($query);
  78. return $query;
  79.  
  80. }
  81.  
  82.  
  83. public static function ShowAllJobsOfferInCouruselIndex()
  84. {
  85. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name')
  86. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  87. ->orderBy('new_job_offer.created_at')
  88. ->get();
  89.  
  90. return $query;
  91. }
  92.  
  93. public static function ShowOneJob($id)
  94. {
  95. $query = JobOffer::
  96. join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  97. ->join('users', 'new_job_offer.company_id', '=', 'users.id')
  98. ->where('new_job_offer.id', '=', $id)
  99. ->get()->first();
  100.  
  101. return $query;
  102. }
  103.  
  104. public static function ShowNewJobOffersInUserSidebar()
  105. {
  106. $query = JobOffer::select('new_job_offer.id','new_job_offer.job_title', 'new_job_offer.location_region', 'companies.name')
  107. ->join('companies', 'new_job_offer.company_id', '=', 'companies.user_id')
  108. ->orderBy('new_job_offer.created_at', 'desc')
  109. ->limit(5)
  110. ->get();
  111.  
  112. return $query;
  113. }
  114.  
  115. public static function GetCompanyIdByOfferId($offer_id){
  116. $query = JobOffer::where('id', '=', $offer_id)
  117. ->pluck('company_id');
  118. $result = company::where('user_id', '=', $query)
  119. ->pluck('id');
  120. return $result;
  121. }
  122.  
  123. public static function Duration(){
  124. $duration = array(
  125. 'Please select',
  126. '1-2 weeks' => '1-2 weeks',
  127. '2-4 weeks' => '2-4 weeks',
  128. '1 month' => '1 month',
  129. '2 months' => '2 moths',
  130. '3-4 months' => '3-4 months',
  131. '5-6 months' => '5-6 months',
  132. );
  133.  
  134. return $duration;
  135. }
  136.  
  137. public static function Experience(){
  138. $experience = array(
  139. 'Please select',
  140. '< 6 months' => '< 6 months',
  141. '> 6 months' => '> 6 months',
  142. '1 year' => '1 year' ,
  143. '2 years' => '2 years' ,
  144. '> 2 years' => '> 2 years' ,
  145. '> 5 years' => '> 5 years' ,
  146. );
  147. return $experience;
  148. }
  149.  
  150. public static function ContractType(){
  151. $contract_type = array(
  152. 'Please select',
  153. 'Temporary' => 'Temporary',
  154. 'Permanent' => 'Permanent',
  155. );
  156.  
  157. return $contract_type;
  158. }
  159.  
  160. public static function category(){
  161.  
  162. $category = array(
  163. 'Please select',
  164. 'Engineers' => array(
  165. 'CH Engineer' => 'CH Engineer',
  166. 'Ch. Engineer <3000kW' => 'Ch. Engineer <3000kW',
  167. '1st Engineer' => '1st Engineer',
  168. '1st Engineer <3000kW' => '1st Engineer <3000kW',
  169. '2nd Engineer' => '2nd Engineer',
  170. '2nd Engineer <3000kW' => '2nd Engineer <3000kW',
  171. '3rd Engineer' => '3rd Engineer',
  172. '4th Engineer' => '4th Engineer',
  173. 'EOOW' => 'EOOW',
  174. 'ETO' => 'ETO',
  175. 'Trainee Engineer' => 'Trainee Engineer',
  176.  
  177. ),
  178. 'Officers' =>array(
  179. 'Captain' => 'Captain',
  180. 'Captain <3000 gt' => 'Captain <3000 gt',
  181. 'Ch. Officer' => 'Ch. Officer',
  182. 'Ch. Officer <300 gt' => 'Ch. Officer <300 gt',
  183. '2nd Officer' => '2nd Officer',
  184. '3nd Officer' => '3nd Officer',
  185. 'OOW' => 'OOW',
  186. 'Trainee Officer' => 'Trainee Officer',
  187.  
  188. ),
  189. 'Ratings' =>array(
  190. 'AB' => 'AB',
  191. 'AB Bosun' => 'AB Bosun',
  192. 'OS' => 'OS',
  193. 'Motorman' => 'Motorman',
  194. 'Oiler' => 'Oiler',
  195. 'Fitter' => 'Fitter',
  196. 'Electrician' => 'Electrician',
  197. 'Welder' => 'Welder',
  198. 'Pumpman' => 'Pumpman',
  199. 'Engine Cadet' => 'Engine Cadet',
  200. 'Deck Cadet' => 'Deck Cadet'
  201.  
  202.  
  203. ),
  204. 'Catering' =>array(
  205. 'Steward/ess' => 'Steward/ess',
  206. 'Cook' => 'Cook',
  207. 'AB-Cook' => 'AB-Cook',
  208. 'Other Catering staff' => 'Other Catering staff',
  209.  
  210. ),
  211. 'Other personnel' =>array(
  212. 'OIM' => 'OIM',
  213. 'SSL' => 'SSL',
  214. 'STSL' => 'STSL',
  215. 'HLO' => 'HLO',
  216. 'Administrator' => 'Administrator',
  217. 'Crane Operator' => 'Crane Operator',
  218. 'Derrickman' => 'Derrickman',
  219. 'Mud Man' => 'Mud Man',
  220. 'Forward planner' => 'Forward planner',
  221. 'Superintendent' => 'Superintendent',
  222. 'Radio Operator' => 'Radio Operator',
  223. 'Geologist' => 'Geologist',
  224. 'Surveyor' => 'Surveyor',
  225. 'Safety Officer' => 'Safety Officer',
  226. 'Driller' => 'Driller',
  227. 'Tool pusher' => 'Tool pusher',
  228. 'Cementer' => 'Cementer',
  229. 'Painter' => 'Painter',
  230. 'Pusher' => 'Pusher',
  231. 'Rigger' => 'Rigger',
  232. 'Deck Foreman' => 'Deck Foreman',
  233. 'Roustabout' => 'Roustabout',
  234. 'ROV Pilot' => 'ROV Pilot',
  235. 'ROV Technician' => 'ROV Technician',
  236. 'ROV Superintedent' => 'ROV Superintedent',
  237. 'ROV Supervisor' => 'ROV Supervisor'
  238.  
  239.  
  240. ),
  241. );
  242.  
  243. return $category;
  244. }
  245.  
  246. public static function Sector(){
  247.  
  248. return array(
  249. 'Please select',
  250. 'Offshore' => 'Offshore',
  251. 'Maritime' => 'Maritime',
  252. );
  253. }
  254.  
  255. public static function TypeOfVessel(){
  256.  
  257. return array(
  258. 'Please select',
  259. 'Barge self-propelled' => 'Barge self-propelled',
  260. 'Barge self-propelled DP' => 'Barge self-propelled DP',
  261. 'Barge non propelled' => 'Barge non propelled',
  262. 'Accommodation Vessel' => 'Accommodation Vessel',
  263. 'Accommodation Vessel DP' => 'Accommodation Vessel DP',
  264. 'AHTS' => 'AHTS',
  265. 'AHTS DP' => 'AHTS DP',
  266. 'Bulker' => 'Bulker',
  267. 'Cable laying vessel' => 'Cable laying vessel',
  268. 'Cable laying vessel DP' => 'Cable laying vessel DP',
  269. 'Chemical/Oil Tanker' => 'Chemical/Oil Tanker',
  270. 'Container vessel' => 'Container vessel',
  271. 'Crew transfer vessel' => 'Crew transfer vessel',
  272. 'Cruise vessel' => 'Cruise vessel',
  273. 'Dredger' => 'Dredger',
  274. 'Dredger DP' => 'Dredger DP',
  275. 'Drillship' => 'Drillship',
  276. 'DSV' => 'DSV',
  277. 'DSV DP' => 'DSV DP',
  278. 'ERRV' => 'ERRV',
  279. 'ERRV DP' => 'ERRV DP',
  280. 'Fixed platform' => 'Fixed platform',
  281. 'FPSO' => 'FPSO',
  282. 'FSIV' => 'FSIV',
  283. 'General Cargo' => 'General Cargo',
  284. 'Heavy lift vessel' => 'Heavy lift vessel',
  285. 'HSSV' => 'HSSV',
  286. 'Jack Up non propelled' => 'Jack Up non propelled',
  287. 'Jack Up self-propelled' => 'Jack Up self-propelled',
  288. 'Jack Up self-propelled DP' => 'Jack Up self-propelled DP',
  289. 'LNG carrier' => 'LNG carrier',
  290. 'LPG carrier' => 'LPG carrier',
  291. 'OSV' => 'OSV',
  292. 'OSV DP' => 'OSV DP',
  293. 'Passenger vessel' => 'Passenger vessel',
  294. 'Pipe laying vessel' => 'Pipe laying vessel',
  295. 'Production Platform' => 'Production Platform',
  296. 'PSV' => 'PSV',
  297. 'PSV DP' => 'PSV DP',
  298. 'RO-PAX' => 'RO-PAX',
  299. 'RO-RO' => 'RO-RO',
  300. 'ROV' => 'ROV',
  301. 'Scientific vessel' => 'Scientific vessel',
  302. 'Seismic vessel' => 'Seismic vessel',
  303. 'SSV ' => 'SSV ',
  304. 'SSV DP' => 'SSV DP',
  305. 'Superyacht' => 'Superyacht',
  306. 'Tug' => 'Tug',
  307.  
  308. );
  309. }
  310.  
  311. public static function Location(){
  312.  
  313. return array(
  314. 'Please select',
  315. 'Australia' => 'Australia' ,
  316. 'Antarctica' => 'Antarctica' ,
  317. 'Arctic' => 'Arctic' ,
  318. 'Antarctic Ocean'=> 'Antarctic Ocean',
  319. 'Asia' => 'Asia' ,
  320. 'Atlantic Ocean' => 'Atlantic Ocean' ,
  321. 'Caspian Sea' => 'Caspian Sea' ,
  322. 'Europe' => 'Europe' ,
  323. 'East Africa' => 'East Africa' ,
  324. 'Indian Ocean' => 'Indian Ocean' ,
  325. 'Meditirean Sea' => 'Meditirean Sea' ,
  326. 'North America' => 'North America' ,
  327. 'North Sea' => 'North Sea' ,
  328. 'Pacific Ocean' => 'Pacific Ocean' ,
  329. 'South America' => 'South America' ,
  330. 'West Africa' => 'West Africa' ,
  331. 'World wide' => 'World wide' ,
  332. );
  333. }
  334.  
  335.  
  336.  
  337.  
  338.  
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement