laravel vue js can't find data ID - laravel

this is my category component
<tr v-for="(categoryList, index) in getCategoryList" :key="categoryList.id">
<td>{{index+1}}</td>
<td>{{categoryList.cat_name}}</td>
<td>
<div class="">
<router-link :to ="'/editCategory/${categoryList.id}'" class="btn btn-sm btn-success"><i class="fa fa-edit"></i></router-link>
<router-link to="" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i></router-link>
</div>
</td>
</tr>
may router
import categoryedit from './components/admin/category/edit.vue';
export const routes = [
{
path: '/editCategory/:categoryId',
component: categoryedit
}
attach file
enter image description here
how to find category id ?

Set router-link as:
<router-link :to ="'/editCategory/'+categoryList.id" class="btn btn-sm btn-success"><i class="fa fa-edit"></i></router-link>

Related

Undefined offset: 2 (View: C:\inetpub\wwwroot\SHDEPHA Portal\resources\views\travel_requests\form.blade.php) on Laravel

Below is my blade codes, the error shows thats its caused by line 307 of the codes.
#endwhile
#endif
Total Request
</table>
<div class="text-center {{$visibility}}">
<button class="btn btn-secondary btn-s add_row_after">
<i class="fa fa-fw" aria-hidden="true" title="Copy to use plus"></i>
Add Row After
</button>
<button class="btn btn-secondary btn-s add_row_before">
<i class="fa fa-fw" aria-hidden="true" title="Copy to use plus"></i>
Add Row Before
</button>
<button class="btn btn-secondary btn-s remove_row">
<i class="fa fa-fw" aria-hidden="true" title="Copy to use minus"></i>
Remove Line
</button>
</div>

how to make readable the url of an image that comes from an api that I created?

I created an api it's been 2 weeks. the api works well but I can't retrieve the images from this api during my HTTP requests.
My Controller Api/admin/AgencyController
`
public function store(AgencyRequest $request)
{
if ($request->hasFile('logo')) {
$path = $request->file('logo')->store('logo','public');
}
$agency=Agency::create([
'name'=>$request->name,
'headquarters'=>$request->headquarters,
'email'=>$request->email,
'logo'=>$path,
'phone_number'=>$request->phone_number,
'state'=>$request->state,
'password'=>bcrypt($request->password),
]);
return new AgencyResource($agency);
}
`
My index file
`
#foreach ($datas as $agencies)
#forelse ($agencies as $agency)
<tr>
<td><img src="{{ url('https://kipart.stillforce.tech/storage/'.$agency->logo) }}" width="48" alt="Product img"></td>
<td><h5>{{ $agency->logo }}</h5></td>
<td>
<i class="zmdi zmdi-edit"></i>
<form method="POST" action="{{ route('admin.agencies.destroy', $agency->id) }}" onsubmit="return confirm('Are you sure?')">
#csrf
#method('delete')
<button type="submit" class="btn btn-default waves-effect waves-float btn-sm waves-red" ><i class="zmdi zmdi-delete" aria-hidden="true" title="Suprimer"></i></button>
</form>
</td>
</tr>
`
#foreach ($datas as $agencies)
#forelse ($agencies as $agency)
<tr>
<td><img src="{{ url('https://kipart.stillforce.tech/storage/'.$agency->logo) }}" width="48" alt="Product img"></td>
<td><h5>{{ $agency->logo }}</h5></td>
<td>
<i class="zmdi zmdi-edit"></i>
<form method="POST" action="{{ route('admin.agencies.destroy', $agency->id) }}" onsubmit="return confirm('Are you sure?')">
#csrf
#method('delete')
<button type="submit" class="btn btn-default waves-effect waves-float btn-sm waves-red" ><i class="zmdi zmdi-delete" aria-hidden="true" title="Suprimer"></i></button>
</form>
</td>
</tr>
When I do a test registration of an agency. all the data is registered but when I retrieve the image to a flutter client or a laravel client the image does not appear but all the data is called

How to add number_format decimal in laravel in html view?

does anyone know how to add the decimal number_format here?, I don't use the blade from Laravel but I route the view directly to html... so if I add the number_format attribute, I'm confused ;(
<tr dir-paginate="income in incomes | filter:searchText | itemsPerPage:20" total-items="totalItems">
<td>{{income.incomeTitle}}</td>
<td>{{income_cat[income.incomeCategory]}}</td>
<td>Rp.{{income.incomeAmount}}</td>
<td>{{income.incomeDate}}</td>
<td>{{income.incomeNotes}}</td>
<td>
<a ng-show="income.incomeImage != ''" target="_blank" href="{{'index.php/incomes/download/'+income.id}}"><button type="button" class="btn btn-success btn-circle" title="{{phrase.Download}}" tooltip><i class="fa fa-cloud-download"></i></button></a>
<button ng-show="$root.can('Incomes.editIncome')" ng-click="edit(income.id)" type="button" class="btn btn-info btn-circle" title="{{phrase.Edit}}" tooltip><i class="fa fa-pencil"></i></button>
<button ng-show="$root.can('Incomes.delIncome')" ng-click="remove(income,$index)" type="button" class="btn btn-danger btn-circle" title="{{phrase.Remove}}" tooltip><i class="fa fa-trash-o"></i></button>
</td>
</tr>

Submit Button not getting correct route to add new data in Laravel

I am facing problem for Submit Button not getting correct route to add new data.
2 Blade file with 2 Submit Button which need to save 2 data to 2 different tables.
Problem facing - Data submitted in 1 table for both submit button....
addnewBuffalo.blade.php
<div class="box-header with-border" align="right">
<button type="submit" class="btn btn-success btn"><i class="fa fa-floppy-o"></i> <b>Add
Buffalo</b></button><a href="" class="btn btn-warning btn"><i class="fa fa-refresh">
</i> <b> Refresh</b></a>
</div>
addnewcow.blade.php
<div class="box-header with-border" align="right">
<button type="submit" class="btn btn-success btn"><i class="fa fa-floppy-o"></i> <b>Add
Cow</b></button><a href="" class="btn btn-warning btn"><i class="fa fa-refresh"></i> <b>
Refresh</b></a>
</div>
web.php
Route:: post('submit', 'App\Http\Controllers\addnewbuffaloController#addbuffaloData')
->name('submit');
Route:: post('submit', 'App\Http\Controllers\addnewcowController#addcowData')
->name('submit');
You need to create 2 separate Route Names. Having ->name('submit') for both won't work. And having the same path won't work
Route::post('submit=buffalo', 'App\Http\Controllers\addnewbuffaloController#addbuffaloData')
->name('submit-buffalo');
Route::post('submit-cow', 'App\Http\Controllers\addnewcowController#addcowData')
->name('submit-cow');
Or if the form is wrapped by one form tag then you can handle both submissions in the one Controller action
<button type="submit" name="buffalo-submission">Save Buffalo</button>
<button type="submit" name="cow-submission">Save Cow</button>
Then in the controller action code you could check
if ($request->has('buffalo-submission') {
Do buffalo code
} else if ($request->has('cow-submission')) {
do cow code
}

Delete from laravel list

i am trying to create a delete and edit button so that i can data from list. please hel how i can do it. in laravel 5.4.Below is the interface of the application and the buttons codes. help on how the edit and delete will work.
<td><a class="btn btn-primary btn-sm" href="#">
<i class="fa fa-pencil-square-o fa-lg" aria-hidden="true"></i> Edit</a> <!-- </td> -->
<!-- <td> --><a class="btn btn-danger btn-sm" href="{{route('contacts.index', $contacts->id)}}" onclick="return confirm('Are you sure to delete the contact');">
<i class="fa fa-trash-o fa-lg" aria-hidden="true"></i> Delete</a></td>
</tr>
enter image description here

Resources