Is it possible to create a button that changes a column value in a table?
I have a column named status in my movimentations table, and I was wondering if it is possible to change the value of this column with a button in my view that can change from active to inactive
this is my view
<div class="container">
<label for="name" class="form-group"><b>Nome</b>: {{ $movs->nameCoop }}</label><br>
<label for="name"><b>Numero</b>: {{ $movs->numCoop }}</label><br>
<label for="name"><b>CPF</b>: {{ $movs->cpfCoop }}</label><br>
<label for="name"><b>Cadastro</b>: {{ $movs->dtCad }}</label><br>
<label for="name"><b>Demissão</b>: {{ $movs->dtDem }}</label><br>
<label for="name"><b>Observações</b>: {{ $movs->description }}</label><br>
<label for="name"><b>Subscritas</b>: {{ $movs->subscritas }}</label><br>
<label for="name"><b>A integralizar</b>: {{ $movs->aintegralizar }}</label><br>
<label for="name"><b>Integralizadas</b>: {{ $movs->integralizadas }}</label><br>
<label for="name"><b>Status</b>: {{ $movs->status }}</label><br>
<td>
<form action="/trans" method="POST">
#csrf
<div class="input-group">
<input type="hidden" class="form-control" name="r" value={{$cooperado->id}}>
<button type="submit" class="btn btn-primary">
<span>+</span>
</button>
</span>
</div>
</form>
</td>
<td>
<form action="/mvs" method="POST">
#csrf
<div class="input-group">
<input type="hidden" class="form-control" name="v" value={{$cooperado->id}}>
<button type="submit" class="btn btn-primary">
<span>ver mvs</span>
</button>
</span>
</div>
</form>
</td>
this is my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Cooperado;
class CooperadoController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
//
//$cooperados = Cooperado::all();
$cooperados = Cooperado::orderBy('dtCad', 'desc')->paginate(10);
return view('cooperados.index', compact('cooperados'));
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
//
return view('cooperados.create');
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$request->validate([
'nameCoop'=>'required',
'numCoop'=> 'required|integer',
'cpfCoop'=> 'required',
'dtCad'=>'required|date',
'subscritas'=>'required'
]);
$cooperado = new Cooperado([
'nameCoop' => $request->get('nameCoop'),
'numCoop'=> $request->get('numCoop'),
'cpfCoop'=> $request->get('cpfCoop'),
'dtCad'=> $request->get('dtCad'),
'description'=> $request->get('description'),
'subscritas'=> $request->get('subscritas'),
'aintegralizar'=> $request->get('subscritas'),
'status'=> $request->get('status')
]);
$cooperado->save();
return redirect('/cooperados')->with('success', 'Cooperado adicionado');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
$cooperado = Cooperado::find($id);
return view('cooperados.show', compact('cooperado'));
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
//
$cooperado = Cooperado::find($id);
return view('cooperados.edit', compact('cooperado'));
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$request->validate([
'nameCoop'=>'required',
'numCoop'=> 'required|integer',
'cpfCoop'=> 'required',
'dtCad'=>'required|date',
'subscritas'=>'required'
]);
$cooperado = Cooperado::find($id);
$cooperado->nameCoop = $request->get('nameCoop');
$cooperado->numCoop = $request->get('numCoop');
$cooperado->cpfCoop = $request->get('cpfCoop');
$cooperado->dtCad = $request->get('dtCad');
$cooperado->dtDem = $request->get('dtDem');
$cooperado->description = $request->get('description');
$cooperado->subscritas = $request->get('subscritas');
$cooperado->integralizadas = $request->get('integralizadas');
$cooperado->aintegralizar = $request->get('aintegralizar');
$cooperado->status = $request->get('status');
$cooperado->save();
return redirect('/cooperados')->with('success', 'Cooperado atualizado');
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
$cooperado = Cooperado::find($id);
$cooperado->delete();
return redirect('/cooperados')->with('success', 'Sucess');
}
}
I've tried to create a function in my route, but didn't work.
I added option button for active and inactive
<form action="/active-deactive" method="POST">
#csrf
<div class="input-group">
<input type="hidden" class="form-control" name="v" value="{{$cooperado->id}}">
<select required class="form-control" id="status" name="status">
<option value="1">Active</option>
<option value="0">De-Active</option>
</select>
</div>
<button type="submit" class="btn btn-primary">
<span>Confirm</span>
</button>
</div>
</form>
controller
public function Confirm(Request $request)
{
$id = $request->input('v');
$status=$request->input('status');
DB::table('tablename')
->where('id',$id)
->update(['status'=>$status]);
}
route
Route::post('/active-deactive','YourController#Confirm')
Of course you can. You can send a request via ajax when clicking on that button:
$.ajax({
type:'POST',
url:'{{ route("NameOfYourRoute") }}',
dataType:'json',
data:{
isActive = $('#theButtonID').val(),
_token = '<?php echo csrf_token() ?>'
},
success:function(data){
if (data.updated) {
alert('Data Updated');
}
}
});
Then in your controller, you can have a function that receives the value of the button (active or inactive) and updated your table in the database:
public function toggleActivity(Request $request)
{
$isActive = $request->get('isActive');
$updated = Model::where(yourCriteria)->update(['isActive' => $isActive]);
return view('YourView', compact('updated'));
}
Related
This type of question has been asked before but not one addresses my particular query. I have tried all the solutions but non seem to work.
I am building a Blog with Laravel and this particular error occurs when I try to edit any of my posts. You are all encouraged to participate. thank you.
edit.blade.php
#extends('layouts.app')
#section('content')
#if(count($errors)>0)
<ul class="list-group">
#foreach($errors->all() as $error)
<li class="list-group-item text-danger">
{{$error}}
</li>
#endforeach
</ul>
#endif
<div class="panel panel-default">
<div class="panel-heading">
Edit post{{$post->title}}
</div>
<div class="panel-body">
<form action="{{ route('post.update', ['id'=>$post->id])}}" method="post" enctype="multipart/form-data">
{{csrf_field()}}
<div class="form-group">
<label for="title">Title</label>
<input type="text" name="title" class="form-control" value="{{$post->title}}">
</div>
<div class="form-group">
<label for="featured">Featured Image</label>
<input type="file" name="featured" class="form-control">
</div>
<div class="form-group">
<label for="category">Select a Category</label>
<select type="file" name="category_id" id="category" class="form-control">
#foreach($categories as $category)
<option value="{{$category->id}}">{{$category->name}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label for="content">Content</label>
<textarea name="content" id="content" cols="5" rows="5" class="form-control" >{{$post->content}}</textarea>
</div>
<div class="form-group">
<div class="text-center">
<button class="btn btn-success" type="submit">Update Post</button>
</div>
</div>
</form>
</div>
</div>
#stop
PostController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Category;
use App\Post;
use Session;
class PostController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
return view('admin.posts.index')->with('posts', Post::all());
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
$categories =Category::all();
if ($categories-> count()==0){
Session::flash('info', 'You must have some categories before attempting to create a post');
return redirect()->back();
}
return view('admin.posts.create')->with('categories', Category::all());
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'title'=> 'required|max:255',
'featured'=>'required|image',
'content'=>'required',
'category_id' => 'required'
]);
$featured=$request->featured;
$featured_new_name= time().$featured->getClientOriginalName();
$featured->move('uploads/posts', $featured_new_name);
$post=Post::create([
'title'=> $request->title,
'content'=> $request->content,
'featured'=> 'uploads/posts/' .$featured_new_name,
'category_id'=> $request->category_id,
'slug' => Str::slug($request->title)
]);
Session::flash('success', 'Post created Successfully');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
$post=Post::find($id);
return view('admin.posts.edit')->with('post', Post::find($id)->with('categories', Category::all()));
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$post =Post::find($id);
$this->validate($request, [
'title'=> 'required',
'content'=>'required',
'category_id'=>'required']
);
if($request->hasfile('featured')){
$featured=$request->featured;
$featured_new_name=time() . $featured->getClientOriginalName();
$featured->move('uploads/posts', $featured_new_name );
$post->featured=$featured_new_name;
}
$post->title=$request->title;
$post->content=$request->content;
$post->category_id=$request->category_id;
$post->save();
Session::flash('success', 'Your post was just updated.');
return redirect()->route('posts');
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
$post =Post::find($id);
$post->delete();
Session::flash('success', 'Your post was just Trashed.');
return redirect()->back();
}
}
Property [title] does not exist on the Eloquent builder instance
This error message is telling you that you are trying to load a property named 'title' on an entity of type 'Eloquent builder'.
Eloquent builder is the type of object which can be used to query the database. The results of a call to ->first() on an Eloquent builder instance would be a Property entity, which is likely what you want.
Please examine and share the code where the Property is being loaded from the database. Do you do something, such as ->first(), to execute the query?
I have made a simple form when I am calling the form from api route it is showing an error that "errors" is an undefined variable when I am calling using web route it just works fine and shows no error. Why is this happening? Since error is a pre defined variable but why is it showing error.
Layout file:
#extends('layout')
#section('content')
<h1 class="title">Simple Form</h1>
<form method="POST" action="/website/atg/public/projects">
#csrf
<div class="field">
<label class="label" for="name">Name</label>
<div class="control">
<input type="text" class="input" name="name" placeholder="Enter Name" value="{{old('name')}}" required>
</div>
</div>
<div class="field">
<label class="label" for="email">E-mail</label>
<div class="control">
<input type="text" class="input" name="email" placeholder="Enter E-mail Address" value="{{old('email')}}" required>
</div>
</div>
<div class="field">
<label class="label" for="pincode">Pincode</label>
<div class="control">
<input type="text" class="input" name="pincode" placeholder="Enter Pincode" value="{{old('pincode')}}" required>
</div>
</div>
<div class="field">
<div class="control">
<button type="submit" class="button">Submit</button>
</div>
</div>
#if($errors->any())
<div class="notification">
<ul>
#foreach($errors->all() as $error)
<li>{{$error}}</li>
#endforeach
</ul>
</div>
#endif
</form>
#endsection
Routes file:
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
/*Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
*/
Route::apiResource('projects','ATGController');
Controller file:
<?php
namespace App\Http\Controllers;
use App\Project;
use App\Mail\ProjectCreated;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
class ATGController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
return view('projects.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)
{
request()->validate([
'name'=>'required|unique:projects,name',
'email'=>'required|email|unique:projects,email',
'pincode'=>'required|digits:6'
]);
if ($validator->fails()) {
return redirect('/projects')
->withErrors($validator)
->withInput();
}
else{
$project=Project::create(request(['name','email','pincode']));
\Mail::to('sbansal1809#gmail.com')->send(
new ProjectCreated($project)
);
//echo '<script>alert("User added sucessfully!")</script>';
return response()->json($project);
}
}
/**
* Display the specified resource.
*
* #param \App\Project $project
* #return \Illuminate\Http\Response
*/
public function show(Project $project)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param \App\Project $project
* #return \Illuminate\Http\Response
*/
public function edit(Project $project)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param \App\Project $project
* #return \Illuminate\Http\Response
*/
public function update(Request $request, Project $project)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param \App\Project $project
* #return \Illuminate\Http\Response
*/
public function destroy(Project $project)
{
//
}
}
you have to return validator fails like this, to be able to get $errors in your blade. Check below example for reference and change the code to your parameters
don't forget to import use Illuminate\Support\Facades\Validator;
public function store(Request $request){
$validator = Validator::make($request->all(), [
'name'=>'required|unique:projects,name',
'email'=>'required|email|unique:projects,email',
'pincode'=>'required|digits:6'
]);
if ($validator->fails()) {
return redirect('/projects/create')
->withErrors($validator)
->withInput();
}else{
$project=Project::create(request(['name','email','pincode']));
\Mail::to('sbansal1809#gmail.com')->send(
new ProjectCreated($project)
);
//echo '<script>alert("User added sucessfully!")</script>';
return response()->json($project);
}
}
Im doing a university project which is a foodlog, where the user is able to log in and then log their food items. Ideally this will post to the database, then the user will be able to view all their logged foods displayed in a table.
at the minute im trying to post the form information to the database and it doesnt seem to work. I also want the user's id to be logged in the database which is a foreign key in the food log table (from users table).
This is my PostsController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class PostsController 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()
{
Post::create([
'id'->request('id');
'user_id'->Auth::user()->id;
'name'->request('name');
'servings'->request('servings');
'servingsize'->request('servingsize');
'calories'->request('calories');
'fat'->request('fat');
]);
return redirect('/foodlog');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
This is my add.blade.php
#extends('layouts.app')
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<form method="POST" action="/posts">
{{ csrf_field() }}
<h1>Add to Foodlog</h1>
<div class="form-group">
<label for="item">Item:</label>
<input type="text" id="name" name="name" class="form-control">
</div>
<div class="form-group">
<label for="noOfServings">Number of Servings:</label>
<input type="number" id="servings" name="servings" class="form-control">
</div>
<div class="form-group">
<label for="servingSize">Serving Size (g):</label>
<input type="number" id="servingsize" name="servingsize" class="form-control">
</div>
<div class="form-group">
<label for="calories">Calories (kcal):</label>
<input type="number" id="calories" name="calories" class="form-control">
</div>
<div class="form-group">
<label for="fat">Fat (g):</label>
<input type="number" id="fat" name="fat" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Add</button>
</form>
</div>
</div>
</div>
#endsection
And my web.php
<?php
Route::get('/', 'FoodlogController#index');
Route::get('/add', 'FoodlogController#add');
Route::get('/account', 'FoodlogController#account');
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
Route::get('/foodlog', function() {
return view('/foodlog');
});
Route::get('/logout', function(){
Auth::logout();
return Redirect::to('welcome');
});
Route::post('/posts', 'PostsController#store');
I have also included a screenshot of my create foodlog migrations file so that you can see the fields in my table
Also my Post model is empty as you can see
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
//
}
Your store function should looks like:
public function store(Request $request)
{
Post::create([
'id' => $request->id, //<--- if this is autoincrement then just delete this line
'user_id' => Auth::user()->id,
'name' => $request->name,
'servings' => $request->servings,
'servingsize' => $request->servingsize,
'calories' => $request->calories,
'fat' => $request->fat
]);
return redirect('/foodlog');
}
For relationship between tables please follow this link
Add to Post model fillable fields:
protected $fillable = [
//if id is not autoincrement then add 'id'
'user_id',
'name',
'servings',
'servingsize',
'calories',
'fat'
];
I have two tables, a table "métier" and a table "tâche" with one to many connection, a "métier" has several "tâche". In my form "ajouter tâches" I have a combobox from which I choose the "métier" associated with the "tâche". When i validate the creation i got the error above. Thank you for helping me.
Create blade.php
#extends('Layouts/app')
#section('content')
#if(count($errors))
<div class="alert alert-danger" role="alert">
<ul>
#foreach($errors ->all() as $message)
<li>{{$message}}</li>
#endforeach
</ul>
</div>
#endif
<div class="container">
<div class="row"></div>
<div class="col-md-12">
<form action=" {{url ('tache') }}" method="post">
{{csrf_field()}}
<div class="form-group">
<label for="">Libelle Tache</label>
<input type="text" name ="libelle_tache" class="form-
control"value="{{old('libelle_tache')}}">
</div>
<div class="form-group">
<label for="">Tarif</label>
<input type="text" name ="Tarif" class="form-
control"value="{{old('tarif')}}">
</div>
<div class="form-group">
<label for="metier">metier</label>
<select name="metier_id" id="metier" class="form-
control">
#foreach($metiers as $metier)
<option value="{{$metier->id}}">
{{$metier->libelle_metier}}
</option>
#endforeach
</select>
</div>
<div class="form-group">
<input type="submit" value = "enregistrer"
class="form-control btn btn-primary">
</div>
</form>
</div>
</div>
<script>
#endsection
tachecontroller.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Tache;
use App\Metier;
class TacheController extends Controller
{
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
$Listmetier=metier::orderBy('libelle_metier')->get();
$Listtache=tache::all();
return view('tache.index',['tache'=>$Listtache]);
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
//$metiers = Costcenter::lists('libelle_metier', 'id');
$metiers = Metier::orderBy('id', 'desc')->get();
return view('tache.create')->with('metiers', $metiers);
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$tache = new Tache();
$tache ->libelle_tache =$request->input('libelle_tache');
$tache ->Tarif =$request->input('Tarif');
$tache ->metier_id =$request->input($tache->id);
$tache->save();
return redirect('tache');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
$tache=Tache::find($id);
return view('tache.edit',['libelle_tache'=>$metier],
['Tarif'=>$tache]);
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
$tache =Tache::find($id);
$tache->delete();
return redirect('tache');
}
}
Model1
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class tache extends Model
{
public function metier()
{
return $this->belongsTo(Metier::class);
}
public function tarificationtache()
{
return $this->hasMany(Tarificationtache::class);
}
}
Model2
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class metier extends Model
{
public function metier()
{
return $this->hasMany(Tache::class);
}
}
screenshot of the form
Change:
$tache ->metier_id = $request->input($tache->id);
To:
$tache ->metier_id = $request->input('metier_id');
I created a login form and a registration form in my eComerace Application but when I submit my login form ( sign in ) it returns nothing ! I have typed username and password correct but my login page is not working.
Routes
Route::get('users/signin', 'UsersController#getSignin');
Route::post('users/signin', 'UsersController#postSignin');
Route::resource('users', 'UsersController');
Route::get('/', 'StoreController#index');
Route::get('store/category/{id}', 'StoreController#getCategory');
Route::get('store/search', 'StoreController#getSearch');
Route::get('/admin', function () {
return view('welcome');
});
Route::resource('store', 'StoreController');
Route::resource('admin/categories', 'CategoriesController');
Route::resource('admin/products', 'ProductsController');
UsersController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\Http\Requests;
use App\Category;
use App\product;
use Hash;
use View;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
class UsersController extends Controller
{
public function __construct(){
parent::__construct();
}
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function getSignin(){
return View::make('users.signin');
}
public function index()
{
return Hash::make('ifti');
}
/**
* Show the form for creating a new resource.
*
* #return \Illuminate\Http\Response
*/
public function create()
{
return View::make('users.newaccount');
}
/**
* Store a newly created resource in storage.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user = new User;
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));
$user->save();
return Redirect::to('users/signin')->with('message','Thank you for creating new account.Sign in now');
}
/**
* Display the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* #param \Illuminate\Http\Request $request
* #param int $id
* #return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
public function getSignout(){
Auth::logout();
return Redirect::to('users/signin')->with('message','Signouted!');
}
public function postSignin(){
$password = Hash::make(Input::get('password'));
$credentials = array('name' => Input::get('name'), 'password' => $password);
if(Auth::attempt($credentials)){
return Redirect::to('http://localhost/ecom/')->with('message','Thanks for signin');
}
return Redirect::to('users/signin')->with('message','Was Incorrect DATA!');
}
}
Signin View
{!! Form::open(array('url' => 'users/signin' , 'method' => 'post')) !!}
<div class="form-group">
<label for="username">User Name:</label>
{!! Form::text('name') !!}
</div>
<div class="form-group">
<label for="username">Password:</label>
{!! Form::password('password') !!}
</div>
<button type="submit" class="btn btn-default">Sign IN</button>
{!! Form::close() !!}
New Account View
<div class="col-md-8 col-lg-8 col-sm-12 col-xs-12">
{!! Form::open(array('url' => 'users/create' , 'method' => 'post')) !!}
<div class="form-group">
<label for="username">User Name:</label>
<input type="username" class="form-control" name="name" id="name">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" name="email" id="name">
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" name="password" id="name">
</div>
<button type="submit" class="btn btn-default">Create New Account</button>
{!! Form::close() !!}
</div>