Incorrect path to public folder - laravel-5

In laravel i given a link that searches the given file in public folder.
Here is the code,
<tr>
<span class="label label-success">
<a href='home.blade.php'>Edit</a>
</span>
<br>
<tr>
But my file is in resources/views,how should i change my code

that's not right way for making link , you should make a route and on that route make that blade file
some thing like this
<a href="{!! route('user_get') !!}">
hope this will help you

Related

How to pass route parameter in a href using Alpine.js

I am using Alpine.js for the first time inside of a Laravel project and would like to add an a href tag to a component however I am unsure how to route the parameter correctly
<template x-for="(post, index) in posts" :key="index">
<a x-bind:href="post.id">
<p class="mt-2 block text-sm font-medium text-gray-900 truncate pointer-events-none">
<span x-text="post.text"></span>
</p>
</a>
</template>
does redirect to
/id
and passes the id but I need to go to the named route posts and expect
/posts/id
if I add
<a x-bind:href="posts/post.id">
the result is a redirect with
/posts/NaN
You can try this: <a x-bind:href="posts + '/' + post.id">

Why does a link with route set to posts.destroy in practice routes to posts.show

#extends('layouts.app')
#section('content')
<ul>
#foreach ($posts as $post)
<li>
<a href="{{route('posts.show', $post->id)}}">
{{$post->title}}
</a>
 
<a href="{{route('posts.edit', $post->id)}}">
Edit
</a>
 
<a href="{{route('posts.destroy', $post->id)}}">
Delete
</a>
#endforeach
</ul>
#endsection
I am new to laravel and in the process of learning. In the code above i have made a simple Unordered list of posts that is in the database. Next to each post is a edit and delete links. The edit link works just fine and invokes edit method in posts controller. But the delete link doesn't work. I think it runs the show method instead of destroy method in posts controller. Why is this the case?
To be more clear i have already somewhat solved the problem with the code bellow inside the foreach directive
<form action="/posts/{{$post->id}}" method="post">
#csrf
<input type="hidden" name="_method" value=" DELETE">
<input type="submit" name="delete" value="Delete" id="">
</form>
But why do this in the first place. I understand when we use form since a html form doesn't support DELETE method i had to add the hidden input. But why doesn't the hyper link tag work. This is the list of routes:
Links always perform GET method by default.
You can mimic DELETE method behavior using some javascript.

spring boot passing parameter from list to controller

I have a list of objects in my view:
<tbody>
<tr th:each="object : ${myObjects}">
<td><span th:text="${object.id}"> </span></td>
<td><span th:text="${object.name}"> </span></td>
<td><span th:text="${object.address}"></span></td>
<td>
<a href="#" data-toggle="modal" data-target="#ADD_SOME_INFO_MODAL">
<i class="fas fa-plus"></i>
</a>
</td>
</tr>
</tbody>
button in last column starts a modal. In modal I can add some value for a record:
<form th:action="#{/add-data}"
method="post"
class="form">
<input name="NEW-DATA">
<div class="modal-footer">
<button name="login-submit"
type="submit">
<i class="fas fa-plus"></i>
</button>
</div>
</form>
and this is my controller:
#PostMapping("/add-data")
public String addData(#RequestParam String URL) {
... do logic...
return "index";
}
I get correct input value in my addData() method, but I cannot find a way to pass an id from object that was clicked on a list in a first place.
I need this object id to be able to correctly store additional information.
I think of maybe doing separate page for adding this information for each record but that seems not right with easy and small eddits/additions.
Is there any way to be able to add edits on modals in Spring Boot? I was not able to find proper answer for that anywhere, so here I am.
You are passing the URL param to the Controller, simply pass the value to the controller in the same way.
The glue you need is in JavaScript. When the user clicks the button to open the modal, use JS to copy the value to a hidden input field on the modal Form tag. When the form is submitted, then your copied value will also be submitted and available in your controller. You can write the hidden input field with a dummy value and then change the value via JS.
<input type="hidden" id="myHiddenField" name="myHiddenField" value="CHANGE_ME">
Your button to open the modal can look like this:
<i class="fas fa-plus" onclick="document.getElementById('myHiddenField').value='${object.id}'"></i>
Now hidden field in modal form has the value you want.

Laravel assigning the ID to a Zurb Foundation modal

I'm currently making a CMS, for a local charity (free of charge) and I'm using Laravel 5.6 along with Zurb foundation 6.4. It's my first time using Laravel, but I've really enjoyed it and I've almost finished.
However, I have a couple of little niggles, that I need to fix, before I deploy it and a little guidance would help, a lot. I'm stuck with assigning a dynamic ID to my modal, to update. My controller, route and model are fine. I can update the first record, from the table, with the modal and that works as expected.
The problem is, it is always the first record that is shown, irrespective of whether I click the trigger, on an unrelated row. I've tried to pass the category_id in, using Blade, but that doesn't work, I either get the same result or an error. I can see what the problem is, but I don't know how to fix it. I think I need some jQuery and/or Ajax and I have tried, to no avail (I'm rubbish with JS).
As I said, my MVC is sound, I can update the first row and all I need is to be able to dynamically assign the category_id to the data-open attribute. I'll post my code, below and thanks for taking time to read this.
#foreach ($categories as $category)
<tr>
<td>{{ $category->name }}</td>
<td>{{ $category->posts->count() }}</td>
<td align="center"><a data-open="editModal"><i class="fas fa-edit fa-lg" style="color: green"></i></a></td>
<td align="center">
<i class="fas fa-trash-alt fa-lg" style="color: red"></i>
</td>
</tr>
<div class="reveal" id="editModal" data-reveal>
<h3>Edit: {{ $category->name }}</h3>
<form action="{{ route('category.update', ['id' => $category->id]) }}" method="post">
{{ csrf_field() }}
<label for="name">Category Name</label>
<input type="text" name="name" value="{{ $category->name }}">
<button class="button expanded success fullRadiusButton" type="submit">Update Category</button>
<i class="fas fa-window-close"></i>
</form>
</div>
#endforeach
An element is unique in the document based on the id property but you're using the same id (editModal) multiple times. You're instructing the Reveal Modal library to open the modal with an id of editModal so it finds the first one (which it expects to be the only one) and opens it. An id should only ever appear once in a document, or you'll experience unexpected behaviour like this.
id - unique to a single element
class - not unique to an element
You can fix this by giving each edit modal a unique id, something like this:
<div class="reveal" id="editModal_{{ $category->id }}" data-reveal>
Then in your trigger reference that unique id:
<a data-open="editModal_{{ $category->id }}">

Laravel 5.2 Eloquent not working in godaddy server

I developed a website in local using Laravel 5.2. All functions are working perfectly. But when I have uploaded it in godaddy server, all functions are working except eloquent. Insert, Update, Delete all works. but in database engine it is showing MYISAM. I change it in INNODB. But still eloquent are not working. Is it the problem of foreign_key constrains?? Error is eloquent variables are not getting data. How to fix it??
Error:
<body>
<div id="sf-resetcontent" class="sf-reset">
<h1>Whoops, looks like something went wrong.</h1>
<h2 class="block_exception clear_fix">
<span class="exception_counter">1/1</span>
<span class="exception_title"><abbr title="Symfony\Component\Debug\Exception\FatalErrorException">FatalErrorException</abbr> in <a title="/home/abhaymilestogo/public_html/floorstyler/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php line 797" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Model.php line 797</a>:</span>
<span class="exception_message">Class '\App\Model\organization' not found</span>
</h2>
<div class="block">
<ol class="traces list_exception">
<li> in <a title="/home/abhaymilestogo/public_html/floorstyler/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php line 797" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Model.php line 797</a></li>
</ol>
</div>
</div>
</body>
agency.blade.php
<tr>
<th>{{$agency['id']}}</th>
<th>{{$agency['name']}}</th>
<th>{{$agency->organization->name}}</th>
<th>{{$agency['status']}}</th>
<th>{{$agency['updated_at']}}</th>
<th>{{$agency['created_at']}}</th>
<th>
<a style="font-size: medium;" class="fa fa-pencil-square-o" href="agency/edit/{{$agency['name']}}/{{Crypt::encrypt($agency['id'])}}"></a>
<a style="font-size: medium;" class="fa fa-trash-o" id="{{Crypt::encrypt($agency['id'])}}"></a>
#if($agency['status'] == 'ALIVE')
<a style="font-size: medium;" class="fa fa-times" id="{{Crypt::encrypt($agency['id'])}}"></a>
#else
<a style="font-size: medium;" class="fa fa-check" id="{{Crypt::encrypt($agency['id'])}}"></a>
#endif
</th>
</tr>
#endforeach
the problem is in {{$agency->organization->name}}
The error clearly states that Class \App\Model\organization not found.
Please check if you have defined the namespace in the Model class 'organization' and verify that the path you are specifying is correct.
Moreover, it is a good practice to always name your classes with the first letter capitalized.
If this does not solve the error, kindly post the file agency.blade.php.

Resources