mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Including FlashMessage Model
This commit is contained in:
parent
cb0c43ba0b
commit
36b62ffc8b
11
app/FlashMessage.php
Normal file
11
app/FlashMessage.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FlashMessage extends Model
|
||||
{
|
||||
const PRIMARY = 'primary';
|
||||
const DANGER = 'danger';
|
||||
}
|
@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use App\FlashMessage;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
@ -72,7 +73,7 @@ class RegisterController extends Controller
|
||||
|
||||
\Mail::to($user)->send(new Welcome($user));
|
||||
|
||||
session()->flash('primary', 'Thanks for registering. Please, do not forget to validate your e-mail address.');
|
||||
session()->flash(FlashMessage::PRIMARY, 'Thanks for registering. Please, do not forget to validate your e-mail address.');
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -5,13 +5,17 @@ namespace App\Http\Controllers;
|
||||
use \App\Item;
|
||||
use \App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\FlashMessage as flash;
|
||||
|
||||
class ItemController extends Controller
|
||||
{
|
||||
public function show($id)
|
||||
{
|
||||
$item = Item::find($id);
|
||||
if (!$item || $item->product->user_id != \Auth::id()) return back();
|
||||
if (!$item || $item->product->user_id != \Auth::id()) {
|
||||
session()->flash(flash::DANGER, "The item doesn't exist.");
|
||||
return back();
|
||||
}
|
||||
$users = $item->users()->get();
|
||||
|
||||
$otherItems = Item::where([['product_id', $item->product_id], ['id', '!=', $id]])->get();
|
||||
|
@ -6,6 +6,7 @@ use \App\Item;
|
||||
use \App\User;
|
||||
use \App\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use App\FlashMessage as flash;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
@ -70,7 +71,7 @@ class ProductController extends Controller
|
||||
$product = Product::fromAuthUser()->find($id);
|
||||
|
||||
if (!$product) {
|
||||
session()->flash('danger', "The product doesn't exist or doesn't belongs to you.");
|
||||
session()->flash(flash::DANGER, "The product doesn't exist or doesn't belongs to you.");
|
||||
return redirect('/product');
|
||||
}
|
||||
return view('product.show', compact('product'));
|
||||
|
Loading…
Reference in New Issue
Block a user