Good day everyone,
please, I am new to Laravel, I am creating a project management app, I created an index page for projects and I have a button where I can be able to create new projects, it is entirely another blade file, I need to display the blade as a modal, I tried using #include and bootstrap modal, but the index page is the one displaying in the modal popup instead of the create page, I don't know where I am getting it wrong, I need help because there is a lot of places I need to use the modal.
This is my index page
#extends('layouts.app')
#section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-right">
<a class="btn btn-success" data-toggle="modal" href="{{ route('projects.create') }}" data-target="#createModal"> New Project</a>
</div>
</div>
</div>
#if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
#endif
<table class="table table-bordered table-hover">
<thead class="text-primary">
<tr>
<th>No</th>
<th>Name</th>
<th>Description</th>
<th>Date Created</th>
<th>Action</th>
</tr>
</thead>
#foreach ($projects as $project)
<tbody class="table-striped">
<tr>
<td>{{ ++$i }}</td>
<td>{{ $project->name }}</td>
<td>{{ $project->introduction }}</td>
<td>{{ $project->created_at->format('d/m/Y') }}</td>
<td>
<form action="{{ route('projects.destroy',$project->id) }}" method="POST">
<a class="fas fa-eye fa-lg text-warning mr-1" href="{{ route('projects.show',$project->id) }}"></a>
<a class="fas fa-edit fa-lg text-primary mr-1" href=" {{ route('projects.edit',$project->id) }}"></a>
#csrf
#method('DELETE')
<button type="submit" class="fa fa-trash fa-lg text-danger" style="border: none; background-color:white;"></button>
</form>
</td>
</tr>
</tbody>
#endforeach
</table>
{!! $projects->links() !!}
#endsection
<div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-labelledby="createModal" data-attr="{{ route('projects.create') }}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
#include('projects.create')
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
while this is the create page
#extends('layouts.modal')
#section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>New Project</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('projects.index') }}"> Back</a>
</div>
</div>
</div>
#if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form action="{{ route('projects.store') }}" method="POST">
#csrf
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Introduction:</strong>
<textarea class="form-control" style="height:50px" name="introduction" placeholder="Introduction"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>location:</strong>
<textarea class="form-control" style="height:150px" name="location" placeholder="Location"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
#endsection
Thank you in advance
I later figure the answer, the mistake I was doing is including the
#extends('layouts.app')
#section('content')
So the page should just be the form or what you want to display without the #extends('layouts.app')
<form action="{{ route('projects.store') }}" method="POST">
#csrf
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Introduction:</strong>
<textarea class="form-control" style="height:50px" name="introduction" placeholder="Introduction"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>location:</strong>
<textarea class="form-control" style="height:150px" name="location" placeholder="Location"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
Related
I'm using Laravel 9 and trying to use CRUD with my model Project which has the following DB table.
When I try to edit a project using the button "edit" on this view:
"projets.index":
#extends('header')
#section('content')
<div class="col-sm-8" style="background: rgba(204, 204, 204,0.5);padding:5%;width:100%">
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2 style="text-align: center">Les projets</h2>
</div>
<div class="pull-right">
<a class="btn btn-success" href="{{ route('projets.create') }}"> Créée un nouveau projet</a>
</div>
</div>
</div>
#if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
#endif
<table class="table table-bordered">
<tr>
<th>id du projet</th>
<th>description</th>
<th width="280px">Action</th>
</tr>
#foreach ($projects as $project)
<tr>
<td>{{ $project->id_project }}</td>
<td>{{ $project->description }}</td>
<td>
<form action="{{ route('projets.destroy',$project->id_project) }}" method="Post">
<a class="btn btn-primary" href="{{ route('galleries.index',$project->id_project,'id_project') }}">ajouter</a>
<a class="btn btn-primary" href="{{ route('projets.edit',[$project->id_project]) }}">Edit</a>
#csrf
#method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
#endforeach
</table>
{!! $projects->links() !!}
</div>
#endsection
I have the following error:
"Missing required parameter for [Route: projets.update] [URI: projets/{projet}] [Missing parameter: projet]."
"projets.edit":
#extends('header')
#section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Edit projet</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('projets.index') }}"> Back</a>
</div>
</div>
</div>
#if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form action="{{ route('projets.update',$project->id_project) }}" method="POST" enctype="multipart/form-data">
#csrf
#method('PUT')
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Company Address:</strong>
<input type="text" name="address" value="{{ $project->description }}" class="form-control" placeholder="Company Address">
#error('address')
<div class="alert alert-danger mt-1 mb-1">{{ $message }}</div>
#enderror
</div>
</div>
<button type="submit" class="btn btn-primary ml-3">Submit</button>
</div>
</form>
#endsection
Update function inside the controller (ProjectController):
public function update(Request $request, $id_project)
{
$request->validate([
'description' => 'required',
]);
User::create($request->all());
$project->description = $request->description;
$project->save();
return redirect()->route('projets.index')
->with('success','project Has Been updated successfully');
}
public function edit(Project $project)
{
return view('projets.edit',compact('project'));
}
Project model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Project extends Model
{
protected $fillable = [
'id_project', 'description'
];
}
Sorry if my questions seems strange English is not my first language
So, i tried laravel and i got stuck when i want to get URL value as a value for my database. Here is the code in my controller.
public function store(Request $request, $shoe_id)
{
//Insert Data
$cart = new Cart;
$cart->user_id = Auth::user()->id;
$cart->shoe_id = $shoe_id;
$cart->quantity = $request->quan;
$cart->save();
return redirect()->back();
}
and here is the problem i've encountered:
it says that the {shoe_id} is string where i wanted to be an integer from the URL
Here what my website looks like:
My blade
Here is my web.php:
Route::get('/','homeController#main')->name('home');
Route::get('/home','homeController#main')->name('home');
Route::get('/detail/{shoe_id}', 'homeController#detail');
Route::get('/cart/{shoe_id}','CartController#show');
Route::post('/cart/{shoe_id}','CartController#store');
Here is my blade:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div style="text-align:center;">
<img src="{{ asset("$cart->shoe_image") }}" alt="" style=" width:350px; height:350px;">
<div class="card-header">{{$cart->shoe_name}}</div>
<div class="card-header">${{$cart->shoe_price}}</div>
<div class="card-header">{{$cart->shoe_description}}</div>
</div>
<div class="card-header form-group">
<form method="POST" action="/cart/{shoe_id}" enctype="multipart/form-data">
#csrf
<div class="form-row">
<div class="col-md-2">
<label for="quantity">Quantity:</label>
</div>
<div>
<input class = "form-control" type="text" id="quantity" name="quan"><br><br>
</div>
<button class="btn btn-primary" type="submit" name="addcart">Add to Cart</button>
</div>
</form>
{{-- <a class="btn btn-primary" href="#">Add to Cart</a> --}}
</div>
</div>
</div>
</div>
</div>
#endsection
what i want to do: input the inputted data to database. My database has table called cart with attribute of id, user_id, shoe_id.
In your form action you should provide the actual value for the shoe_id then it will work as expected. action="/cart/{{ $cart->shoe_id }}"
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div style="text-align:center;">
<img src="{{ asset("$cart->shoe_image") }}" alt="" style=" width:350px; height:350px;">
<div class="card-header">{{$cart->shoe_name}}</div>
<div class="card-header">${{$cart->shoe_price}}</div>
<div class="card-header">{{$cart->shoe_description}}</div>
</div>
<div class="card-header form-group">
<form method="POST" action="/cart/{{ $cart->shoe_id }}" enctype="multipart/form-data">
#csrf
<div class="form-row">
<div class="col-md-2">
<label for="quantity">Quantity:</label>
</div>
<div>
<input class = "form-control" type="text" id="quantity" name="quan"><br><br>
</div>
<button class="btn btn-primary" type="submit" name="addcart">Add to Cart</button>
</div>
</form>
{{-- <a class="btn btn-primary" href="#">Add to Cart</a> --}}
</div>
</div>
</div>
</div>
</div>
#endsection
I create a laravel destroy function and i use a modal to delete data. but i cannot delete all data in my database. last one cannot be deleted. i think it cause in view.
this is my modal popup in view
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="post">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
And my destroy controller
public function destroy(Account $account)
{
$findAccount = Account::find($account->id);
if($findAccount->delete()){
return redirect()->route('account.index')->with('success', 'Account details delete successfully!');
}
return back()->withInput()->with('error', 'Account details could not be deleted.');
}
i cannot delete all data in table. they keep one data and it cannot be deleted.
Try this:
#extends('template.app')
#section('content')
<div class="col-md-9">
<!-- table content -->
<div class="card">
<div class="card-header main-color-bg">
<h3 class="card-title">Account Details</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<input class="form-control rounded-corner" type="text" placeholder="Search Member Here" style="margin-bottom: 20px;">
</div>
</div>
<!-- success message -->
#include('inc.message')
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Account Number</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
#if(is_empty($accounts))
<tr><td>NO DATA</td></tr>
#else
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#endif
</tbody>
</table>
<!-- pagination -->
<nav id="pagination">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<span class="page-link"><span class="fa fa-arrow-circle-left"></span></span>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<span class="page-link">
2
<span class="sr-only">(current)</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#"><span class="fa fa-arrow-circle-right"></span></a>
</li>
</ul>
</nav>
<!-- end pagination -->
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal"><span class="fa fa-plus"></span> Add Account</button>
</div>
</div>
<!-- end table content -->
</div>
<!-- delete modal -->
<!-- Modal -->
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="delete">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- end delete modal-->
<!-- modal popup -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #309fe2; color: #fff;">
<h5 class="modal-title" id="exampleModalLabel">Account Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{!! Form::open(['url' => '/account', 'id' => 'eventForm', 'data-toggle' => 'validator', 'role' => 'form']) !!}
{{ csrf_field() }}
<div class="modal-body">
<!-- modal form -->
<div class="form-group">
<label for="acc_no">Account Number</label>
<input type="number" class="form-control" name="acc_no" id="acc_no" maxlength="20" placeholder="Enter your account number" required>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" maxlength="30" name="name" id="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label for="id_no">Identity No</label>
<input type="number" class="form-control" maxlength="9" name="id_no" id="id_no" placeholder="Enter your identity no" required>
</div>
<div class="form-group">
<label for="bank_id">Bank</label>
<select class="form-control" name="bank_id">
#if(!empty($banks))
#foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
#endforeach
#endif
</select>
</div>
<div class="form-group">
<label for="acc_type">Account Type</label>
<select class="form-control" id="acc_type" name="acc_type">
<option value="Saving">Saving</option>
<option value="Current">Current</option>
<option value="Deposite">Deposite</option>
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="text" pattern="[0-9.]" class="form-control" maxlength="15" name="amount" id="amount" placeholder="Enter your amount" required>
</div>
<!-- end modal form -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><span class="fa fa-times-circle"></span> Close</button>
<button type="submit" class="btn btn-primary pull-right"><span class="fa fa-money"></span> Save changes</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<!-- end modal -->
#endsection
On your delete form change method from POST to DELETE.
I think may be Account::find($account->id); did not get the right Account object. use findOrFail to have another shot:
public function destroy(Account $account)
{
$findAccount = Account::findOrFail($account->id);
...
}
this is my table view. where i put if statement
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#extends('template.app')
#section('content')
<div class="col-md-9">
<!-- table content -->
<div class="card">
<div class="card-header main-color-bg">
<h3 class="card-title">Account Details</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<input class="form-control rounded-corner" type="text" placeholder="Search Member Here" style="margin-bottom: 20px;">
</div>
</div>
<!-- success message -->
#include('inc.message')
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Account Number</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
#if(!empty($accounts))
#foreach($accounts as $account)
<tr>
<th scope="row">{{$account->id}}</th>
<td>{{$account->acc_no}}</td>
<td>{{$account->acc_type}}</td>
<td>{{$account->amount}}</td>
<td><a class="btn btn btn-secondary" href="{{route('account.edit', $account->id)}}"><span class="fa fa-pencil"></span> Edit</a> <a class="btn btn btn-danger"
data-toggle="modal" data-target="#delete-form"><span class="fa fa-trash-o"></span> Delete</a></td>
</tr>
#endforeach
#endif
</tbody>
</table>
<!-- pagination -->
<nav id="pagination">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<span class="page-link"><span class="fa fa-arrow-circle-left"></span></span>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<span class="page-link">
2
<span class="sr-only">(current)</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#"><span class="fa fa-arrow-circle-right"></span></a>
</li>
</ul>
</nav>
<!-- end pagination -->
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal"><span class="fa fa-plus"></span> Add Account</button>
</div>
</div>
<!-- end table content -->
</div>
<!-- delete modal -->
<!-- Modal -->
<div class="modal fade" id="delete-form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="delete-form" action="{{ route('account.destroy', [$account->id]) }}" method="delete">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<p>Are you sure you want to delete this data? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- end delete modal-->
<!-- modal popup -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #309fe2; color: #fff;">
<h5 class="modal-title" id="exampleModalLabel">Account Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{!! Form::open(['url' => '/account', 'id' => 'eventForm', 'data-toggle' => 'validator', 'role' => 'form']) !!}
{{ csrf_field() }}
<div class="modal-body">
<!-- modal form -->
<div class="form-group">
<label for="acc_no">Account Number</label>
<input type="number" class="form-control" name="acc_no" id="acc_no" maxlength="20" placeholder="Enter your account number" required>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" maxlength="30" name="name" id="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label for="id_no">Identity No</label>
<input type="number" class="form-control" maxlength="9" name="id_no" id="id_no" placeholder="Enter your identity no" required>
</div>
<div class="form-group">
<label for="bank_id">Bank</label>
<select class="form-control" name="bank_id">
#if(!empty($banks))
#foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
#endforeach
#endif
</select>
</div>
<div class="form-group">
<label for="acc_type">Account Type</label>
<select class="form-control" id="acc_type" name="acc_type">
<option value="Saving">Saving</option>
<option value="Current">Current</option>
<option value="Deposite">Deposite</option>
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="text" pattern="[0-9.]" class="form-control" maxlength="15" name="amount" id="amount" placeholder="Enter your amount" required>
</div>
<!-- end modal form -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><span class="fa fa-times-circle"></span> Close</button>
<button type="submit" class="btn btn-primary pull-right"><span class="fa fa-money"></span> Save changes</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<!-- end modal -->
#endsection
I am doing the CMS.. How should I able to limit the activated images with message? For example I would like to limit 5 activated image and I also would like to put some message if he exceed to the limit like "Only 5 activated images only!"
I already tried this but the message wont display(I also checked the $result).. Is there something wrong in my codes? What is it?
View
#extends('dashboard')
#section('content')
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Upload New Image</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="titleLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header modal-header-success">
<button type="button" class="close btn btn-primary" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="titleLabel">New Image</h4>
</div>
<div class="modal-body">
<div class="container">
<div class="panel-body">
<div class="text-content">
<div class="col-md-2 col-lg-5">
<br>
#if($errors->first('image'))
<p class="errors">
<div class = "alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
{!!$errors->first('image')!!}
</ul>
</div>
</p>
#endif
#if ($message = Session::get('failed'))
<div class="alert alert-success alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
#endif
<h4>Choose to Upload:</h4>
<div class="col-md-2 col-lg-2">
<form action="{{ url('file-upload') }}" enctype="multipart/form-data" method="POST">
{{ csrf_field() }}
<div class="row">
<div class="col-md-12">
<input type="file" class = "filestyle"name="image" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<span class="pull-right">
<button type="submit" class="btn btn-success">Upload File</button>
</span>
</form>
</div>
</div>
</div>
</div>
<br><br>
#if ($message = Session::get('success'))
<div class="alert alert-success alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
#endif
<div class="x_content">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Image</th>
<th>Action</th>
<th>Status</th>
</tr>
</thead>
<tbody>
#foreach($data as $image)
<tr>
<th scope="row">{{ $image->id }}</th>
<td><img src="/assets/img/{{$image->img_jumbotron}}" width ="50px"> </td>
<td>
#if($image->status=="Activated")
<form action="/deactivateImage/{{ $image->id}}" method="post">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<button type="submit" class="btn btn-primary">Deactivate</button>
</form>
#else
<form action="{{ url('activateImage', ['id' => $image->id]) }}" method="post">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<button type="submit" class="btn btn-primary">Activate</button>
</form>
</td>
#endif
<td>{{$image->status}}</td>
</tr>
#endforeach
</tbody>
</table>
</div>
#stop
Controller
public function activateImage($id)
{
$result = jumbotron::where(['status' => 'Activated'])->count();
if($result > 5)
{
return back()->with('failed', 'Only 5 images can be activated!');
}
else
{
echo "not yet";die;
}
return back()->with('activated','Image Activated successfully.');
}
You should return redirect():
return redirect()->back()->with('failed', 'Only 5 images can be activated!');
I have created a view that shows 2 columns on medium and large screens but only 1 column on small and extra small screens. I'm using the push and pull classes from bootstrap to reorder my panels at different screen sizes.
My problem is that on small and extra small screen sizes some of my links and buttons are not clickable.
I have followed this thread Links in bootstrap grid stop working in small screen mode. It says the problem is that the links are floated, resulting in a height of 0 for the parent container.
I have tried using the "clearfix" class. I've also created my own class using overflow:auto and another using overflow:hidden and none of these work.
I have never had this problem before but this is the first time I've used push/pull. Would you take a look at my code and see if you can spot the problem?
<div class="container">
<!--*********************************Modal for notes**********************************************************-->
<div class="modal fade" id="myModal" name="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="myModalLabel">Notes</h3>
</div>
<div class="modal-body">
<form method="post" action="/notes/save" role="form" name="new_note">
{!! csrf_field() !!}
<div class="form-group">
<label for="note">Type a new note for this client. (The current date will be automatically added.)</label>
<textarea class="form-control" rows="15" name="note" id="note" required></textarea>
<input type="hidden" name="ind_id" value="{{ $id }}">
<input type="hidden" name="timestamp" id="timestamp">
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" value="Save Changes" onclick="this.form.timestamp.value=Date.now()">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>
</div>
</div>
</div>
</div>
<!--***********************************End modal code***********************************************************-->
<div class="row">
<div class="col-md-8 col-md-push-4 col-lg-9 col-lg-push-3">
<!--************************************Name and Address********************************************************-->
<div class="panel panel-primary">
<div class="panel-heading">Name and Address</div>
<div class="panel-body">
<address class="col-md-6">
<strong>{{ $ind->name }}</strong><br>
#if ($ind->MailingStreet)
{{ $ind->MailingStreet }}<br>
#endif
#if ($ind->MailingCity || $ind->MailingState || $ind->MailingPostalCode)
{{ $ind->MailingCity . ", " . $ind->MailingState . " " . $ind->MailingPostalCode }}
#endif
</address>
<address class="col-md-6">
#if ($ind->OtherStreet || $ind->OtherCity || $ind->OtherState || $ind->OtherPostalCode)
<strong>Other Address</strong><br>
#endif
#if ($ind->OtherStreet)
{{ $ind->OtherStreet }}<br>
#endif
#if ($ind->OtherCity || $ind->OtherState || $ind->OtherPostalCode)
{{ $ind->OtherCity . ", " . $ind->OtherState . " " . $ind->OtherPostalCode }}
#endif
</address>
</div>
</div>
<!--*******************************************End Name and Address***************************************-->
<!--*******************************************Contact Info***********************************************-->
<div class="panel panel-danger">
<div class="panel-heading">Contact Info</div>
<div class="panel-body">
#if ($ind->Cell_Phone)
<div class="col-md-5 col-sm-6"><strong>Cell Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Cell_Phone }}</div>
#endif
#if ($ind->Spouse_Cell_Phone)
<div class="col-md-5 col-sm-6"><strong>Spouse Cell Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Cell_Phone }}</div>
#endif
#if ($ind->Business_Phone)
<div class="col-md-5 col-sm-6"><strong>Business Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Business_Phone }}</div>
#endif
#if ($ind->Spouse_Business_Phone)
<div class="col-md-5 col-sm-6"><strong>Spouse Business Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Business_Phone }}</div>
#endif
#if ($ind->HomePhone)
<div class="col-md-5 col-sm-6"><strong>Home Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->HomePhone }}</div>
#endif
#if ($ind->Fax)
<div class="col-md-5 col-sm-6"><strong>Fax</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Fax }}</div>
#endif
#if ($ind->Email)
<div class="col-md-5 col-sm-6"><strong>Email</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Email }}</div>
#endif
#if ($ind->Spouse_Email)
<div class="col-md-5 col-sm-6"><strong>Spouse Email</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Email }}</div>
#endif
#if ($ind->Return_Type)
<div class="col-md-5 col-sm-6"><strong>Return Type</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Return_Type }}</div>
#endif
</div>
</div>
<!--*********************************************End Contact Info******************************************-->
</div>
<div class="col-sm-12 col-md-4 col-md-pull-8 col-lg-3 col-lg-pull-9 pull-right">
<!--*******************************************Options***********************************************************-->
<ul class="list-group">
<li class="list-group-item">
<i class="fa fa-pencil-square-o"></i> Edit Client
</li>
<li class="list-group-item">
<i class="fa fa-times"></i> Delete Client
</li>
<li class="list-group-item">
<button type="button" class="btn btn-success btn-block no-print" data-toggle="modal" data-target="#myModal"><i class="fa fa-sticky-note-o"></i> Add Note</button>
</li>
<!--********************Link Form*****************************************-->
<li class="list-group-item">
<form action="/links/save" method="post" class="form-inline">
{!! csrf_field() !!}
<div class="input-group btn-block">
<input id="autocomplete" type="text" class="form-control autocomplete no-print" name="client" placeholder="Add link..." required>
<input id="autocomplete-value" type="hidden" name="autocomplete-value" class="autocomplete-value">
<input id="ind_id" name="ind_id" type="hidden" value="{{ $id }}">
<span class="input-group-btn">
<button type="submit" class="btn btn-success no-print" style="height:36px;">Go</button>
</span>
</div>
</form>
</li>
<!--***********************End Link form*************************************-->
</ul>
<!--***************************************End Options*********************************************************-->
<!--************************************************Routing sheet starts here*********************************************************-->
#if(isset($routing_sheet))
<div class="panel panel-info" id="2015_routing_sheet">
<div class="panel-heading" role="tab" id="headingOne">2015 Tax Return</div>
<ul class="list-group">
#foreach($routing_sheet as $r)
<form action='/individuals/tax_return_2015' method='post'>
{!! csrf_field() !!}
#if($r->user_name)
<li class="list-group-item" style="padding: 5px 5px 5px 5px;">
<div>
<button
type='submit'
class='btn btn-success btn-xs'
name='button'
value="Clear"
onclick="return confirm('Are you sure you want to clear this event?')">
<i class="fa fa-check" aria-hidden="true"></i>
</button>
<strong>{{ $r->name }}</strong>
</div>
<div>
{{ $r->user_name }}
{{ $r->date ? date('m/d/Y h:i a', strtotime($r->date)) : '' }}
</div>
<input type='hidden' name='routing_events_id' id='routing_events_id' value='{{ $r->id }}'>
<input type='hidden' name='routing_data_id' id='routing_data_id' value='{{ $r->routing_data_id }}'>
</li>
#else
<li class="list-group-item" style="padding: 5px 5px 5px 5px;">
<button
type='submit'
class='btn btn-danger btn-xs'
name='button'
value="Done"
onclick='this.form.timestamp.value=Date.now()'>
<i class="fa fa-square-o" aria-hidden="true"></i>
</button>
<strong>{{ $r->name }}</strong>
{{ $r->user_name }}
{{ $r->date ? date('m/d/Y h:i a', strtotime($r->date)) : '' }}
<input type='hidden' name='routing_events_id' id='routing_events_id' value='{{ $r->id }}'>
<input type='hidden' name='routing_data_id' id='routing_data_id' value='{{ $r->routing_data_id }}'>
</li>
#endif
<input id="ind_id" name="ind_id" type="hidden" value="{{ $id }}">
<input type="hidden" name="timestamp" id="timestamp">
</form>
#endforeach
</ul>
</div>
#endif
<!--*********************************************Routing Sheet ends here***********************************************-->
</div>
<div class="col-md-8 col-md-push-4 col-lg-9 col-lg-push-3">
<!--*******************************************Links**********************************************************-->
<div class="panel panel-warning">
<div class="panel-heading">Links</div>
<ul class="list-group">
<!--******************Start of displaying links*****************-->
#if(count($links_ind))
#foreach($links_ind as $link)
<li class="list-group-item">
<div class="row">
<div class="col-md-1 col-xs-1">
<a
href='/links/delete/{{ $link->link_id }}'
class='btn btn-danger btn-sm no-print'
onclick="return confirm ('Are you sure you want to delete this link?')">
<i class="fa fa-times"></i>
</a>
</div>
<div class="col-md-11 col-xs-11">
<div class="col-md-4 col-sm-5"><strong>Name</strong></div>
<div class="col-md-8 col-sm-7">
<a href='/individuals/{{ $link->ind_id }}'>{{ $link->FirstName.' '.$link->LastName }}</a>
</div>
#if ($link->Business_Phone)
<div class="col-md-4 col-sm-5"><strong>Business Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Business_Phone }}</div>
#endif
#if ($link->Cell_Phone)
<div class="col-md-4 col-sm-5"><strong>Cell Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Cell_Phone }}</div>
#endif
#if ($link->Spouse_Cell_Phone)
<div class="col-md-4 col-sm-5"><strong>Spouse Cell Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Spouse_Cell_Phone }}</div>
#endif
#if ($link->HomePhone)
<div class="col-md-4 col-sm-5"><strong>Home Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->HomePhone }}</div>
#endif
</div>
</div>
</li>
#endforeach
#endif
#if(count($links_bus))
#foreach($links_bus as $link)
<li class="list-group-item">
<div class="row">
<div class="col-md-1 col-xs-1">
<a href='/links/delete/{{ $link->link_id }}'
class='btn btn-danger btn-sm no-print'
onclick="return confirm ('Are you sure you want to delete this link?')">
<i class="fa fa-times"></i>
</a>
</div>
<div class="col-md-11 col-xs-11">
<div class="col-md-4 col-sm-5"><strong>Name</strong></div>
<div class="col-md-7 col-sm-7">
<a href='/businesses/{{ $link->bus_bus_id }}'>{{ $link->company_name }}</a>
</div>
#if ($link->business_phone)
<div class="col-md-4 col-sm-5"><strong>Business Phone</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->business_phone }}</div>
#endif
#if ($link->cell_phone)
<div class="col-md-4 col-sm-5"><strong>Cell Phone</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->cell_phone }}</div>
#endif
#if ($link->fax)
<div class="col-md-4 col-sm-5"><strong>Fax</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->fax }}</div>
#endif
#if ($link->email)
<div class="col-md-4 col-sm-5"><strong>Email</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->email }}</div>
#endif
</div>
</div>
</li>
#endforeach
#endif
</ul>
</div>
<!--*******************************************************End of displaying links*************************************************-->
<!--*****************************************start of displaying notes************************************************-->
<div class="panel panel-success">
<div class="panel-heading">Notes</div>
<ul class="list-group">
#if(count($notes))
<!--***********************************Modal for each note*******************************************-->
#foreach($notes as $note)
<div class='modal fade'
id='myModal{{ $note->id }}'
name='myModal{{ $note->id }}'
tabindex='-1'
role='dialog'
aria-labelledby='myModalLabel'>
<div class='modal-dialog modal-lg' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
<h3 class='modal-title' id='myModalLabel'>Edit Note</h3>
</div>
<form method='post' action='/notes/save' role='form' name='new_note'>
{!! csrf_field() !!}
<div class='modal-body'>
<div class='form-group'>
<label for='note'>Edit the note and save your changes.</label>
<textarea class='form-control' rows='15' name='note' id='note' required>{{ $note->note }}</textarea>
<input type='hidden' name='ind_id' id='ind_id' value="{{ $id }}">
<input type='hidden' name='note_id' id='note_id' value="{{ $note->id }}">
<input type='hidden' name='timestamp' id='timestamp'>
</div>
</div>
<div class='modal-footer'>
<input type='submit' class='btn btn-primary' value='Save Changes' onclick='this.form.timestamp.value=Date.now()'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</form>
</div>
</div>
</div>
<!--*****************************************End Modal for each note****************************************-->
<li class="list-group-item">
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12"><pre class="pre-note">{{ $note->note }}</pre></div>
</div>
</li>
#endforeach
#endif
</ul>
</div>
<!--******************************************end of displaying notes***************************************************-->
<!--*****************************************start of displaying invoices***********************************************
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Invoices</h3>
</div>
<div class="panel-body">
<ol>
#foreach($invoices as $invoice)
<li><a href='/invoice/pdf/{{ $invoice->id }}'>{{ date('m-d-Y', strtotime($invoice->date)) }}</a> {{ '$' . $invoice->amount }}</li>
#endforeach
</ol>
</div>
</div>
<!****************************************end of displaying invoices**************************************************-->
</div>
<script>
//This encodes the PHP array as JSON so that the autocomplete.js script can use it
var dataTwo = {!! $dataTwo !!};
</script>
</div>
</div>
Thank you
Jason
I didn't go through your whole code, but here is what I think is the problem. if for example you have a situation where you need to show
different number of columns on different screen sizes with bootstrap, please be specific with all column sizes. Don't let bootstrap guess.
here is what I mean:
for example you have this code:
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12"><pre class="pre-note">{{ $note->note }}</pre></div>
You can see that you have specified the following for extra small screens: "col-xs-4", and "col-xs-8" for the first and second div's respectevely. What
about the third div? You have implied that it is "col-xs-12". I am afraid you will have to explicitely say that it is "col-xs-12".
so if you were to change your code to :
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12"><pre class="pre-note">{{ $note->note }}</pre></div>
It is going to work without any problem. Notice the explicit "col-xs-12" for the last div. The problem is on xtra small screens the first and second div's are floated left because they have "col-xs-..." whilst the third div is not floated and ends up causing chaos!
Have fun!!