<?php
namespace App\Http\Controllers;
use App\Job;
use Illuminate\Http\Request;
class JobController extends Controller
{
public function __construct()
{
$this->middleware('recruiter')->except('index','show');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$jobs = \App\Job::all();
return view ('searchresults', compact('jobs'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
$industries = \App\Industry::all();
return view('listjob', compact('industries'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$this->validate($request, [
//'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'title' => 'required|max:50|min:5',
'body' => 'required|max:1000|min:50',
'location' => 'required',
'salary' => 'required',
'industry' => 'required',
]);
//geocode the location
$location = \Geocoder::getCoordinatesForAddress(request('location'));
/* if ($request->file('image')->isValid()) {
$path = $request->photo->store('images');
dd($path);
}*/
$job = \App\Job::create([
'title' => request('title'),
'body' => request('body'),
'location' => $location['formatted_address'],
'salary' => request('salary'),
'lat' => $location['lat'],
'long' => $location['lng'],
'user_id' => \Auth::id(),
]);
$job->industry()->attach(request('industry'));
$job->save();
dd($job);
}
/**
* Display the specified resource.
*
* @param \App\Job $job
* @return \Illuminate\Http\Response
*/
public function show(Job $job)
{
//
dd($job);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Job $job
* @return \Illuminate\Http\Response
*/
public function edit(Job $job)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Job $job
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Job $job)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Job $job
* @return \Illuminate\Http\Response
*/
public function destroy(Job $job)
{
//
}
}