|
|
@@ -0,0 +1,121 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers;
|
|
|
+
|
|
|
+use App\Models\foo;
|
|
|
+use App\Models\User;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+
|
|
|
+class FooController extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Display a listing of the resource.
|
|
|
+ *
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ //
|
|
|
+ //$users = \App\Models\foo::factory(3)->create();
|
|
|
+ $users = Foo::all();
|
|
|
+ $users = Foo::where('id', '>', 3)->first();
|
|
|
+ $name = $this->show($users);
|
|
|
+ return $name;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Show the form for creating a new resource.
|
|
|
+ *
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function create()
|
|
|
+ {
|
|
|
+ //
|
|
|
+
|
|
|
+ $user = Foo::where('id', '>', 3)->orderBy('id', 'desc')->first();
|
|
|
+ echo ('test');
|
|
|
+ $foo = Foo::Create([
|
|
|
+ 'name' => 'test4',
|
|
|
+ 'email' => 'foo2222@gmail.com',
|
|
|
+ 'fk_tests_id' => 1,
|
|
|
+ ]);
|
|
|
+ return $foo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Store a newly created resource in storage.
|
|
|
+ *
|
|
|
+ * @param \Illuminate\Http\Request $request
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function store(Request $request)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ $foo = new Foo;
|
|
|
+
|
|
|
+ $foo->name = $request->name;
|
|
|
+ $foo->email = $request->email;
|
|
|
+ $foo->email_verified_at = $request->email_verified_at;
|
|
|
+
|
|
|
+ $foo->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Display the specified resource.
|
|
|
+ *
|
|
|
+ * @param \App\Models\foo $foo
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function show(foo $foo)
|
|
|
+ {
|
|
|
+ $foo = Foo::where('foos.id', '>', 1)
|
|
|
+ ->leftjoin('fk_tests', 'fk_tests.id', '=', 'foos.fk_tests_id')
|
|
|
+ ->select('foos.*', 'fk_tests.name as fk_name', 'fk_tests.id as fk_id')
|
|
|
+ ->get();
|
|
|
+ return $foo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Show the form for editing the specified resource.
|
|
|
+ *
|
|
|
+ * @param \App\Models\foo $foo
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function edit(foo $foo)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Update the specified resource in storage.
|
|
|
+ *
|
|
|
+ * @param \Illuminate\Http\Request $request
|
|
|
+ * @param \App\Models\foo $foo
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function update(Request $request, foo $foo)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ $foo = foo::where('name', 'test2')->get()[0];
|
|
|
+ // $foo = foo::find(1);
|
|
|
+ $foo->email = $request->email;
|
|
|
+ $foo->save();
|
|
|
+
|
|
|
+ // foo::where('name', 'oransheep')
|
|
|
+ // ->update(['email' => $request->email]);
|
|
|
+
|
|
|
+ return $foo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Remove the specified resource from storage.
|
|
|
+ *
|
|
|
+ * @param \App\Models\foo $foo
|
|
|
+ * @return \Illuminate\Http\Response
|
|
|
+ */
|
|
|
+ public function destroy(foo $foo)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ }
|
|
|
+}
|