Commit 3e79e3bc by hfpp2012 yinsigan

migration

1 parent 3ceab15e
<?php
namespace App\Http\Controllers;
use App\Photo;
use Illuminate\Http\Request;
class PhotoController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Photo $photo
* @return \Illuminate\Http\Response
*/
public function show(Photo $photo)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Photo $photo
* @return \Illuminate\Http\Response
*/
public function edit(Photo $photo)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Photo $photo
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Photo $photo)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Photo $photo
* @return \Illuminate\Http\Response
*/
public function destroy(Photo $photo)
{
//
}
}
......@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
class UsersController extends Controller
{
......@@ -21,4 +22,15 @@ class UsersController extends Controller
// return $users;
return view('admin.users.index', compact('users'));
}
public function create()
{
return view('admin.users.create');
}
public function store(Request $request)
{
User::create($request->all());
return "success";
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Photo extends Model
{
//
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePhotosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photos', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('photos');
}
}
<form action="/users" method="POST">
{{ csrf_field() }}
<input type="text" name="name">
<input type="email" name="email">
<input type="password" name="password">
<input type="submit" vaule="Create">
</form>
<ul>
@foreach($users as $user)
<li>{!! $user['first_name'] !!} {!! $user['last_name'] !!}</li>
<li>{{ $user['first_name'] }} {{ $user['last_name'] }}</li>
@endforeach
</ul>
......@@ -30,3 +30,5 @@ Route::get('/', function () {
// });
Route::get('/users', 'UsersController@index');
Route::get('/users/create', 'UsersController@create');
Route::post('/users', 'UsersController@store');
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!