You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.2 KiB

<?php
namespace App\Http\Controllers;
use App\Home;
use App\Parser;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
$homes = Home::all();
return view('homes.home', ['homes' => $homes]);
}
public function show($id, Request $request)
{
return view('homes.view', ['home' => Home::where('id', $id)->firstOrFail()]);
}
public function add()
{
return view('homes.add');
}
public function store(Request $request)
{
$inputs = $request->all();
$home = new Home();
foreach ($inputs as $input_name => $input_value) {
if ($input_name === '_token') {
continue;
}
$home->$input_name = $input_value;
}
$home->save();
return redirect(route('home'));
}
/**
* @param \Illuminate\Http\Request $request
*
* @return false|string
*/
public function fetch(Request $request)
{
return json_encode(Parser::factory($request->input('url'))->parse());
}
}