Questions tagged [laravel-4]

Laravel 4.2, the former iteration of the popular open-source PHP web development MVC framework developed by Taylor Otwell, offers a user-friendly and expressive syntax for building applications.

Guide to refreshing the webpage content via ajax with Laravel View/Layout approach

Currently utilizing Laravel 4, I am looking to refresh a view and update the content (essentially change the language) Upon arriving at the index page : In my controller : public function getIndex() { $lang = $this->retrieveLang("FR"); ...

Despite Laravel 4 seed showing successful completion, the database remains empty

Currently, I am using Laravel 4 and attempting to seed the database with some users. Instead of extending from Eloquent, my User model extends ConfideUser as per the instructions due to the use of the Zizaco Confide plugin. I have also made some modificati ...

Exploring Laravel 4.2 queries on a database with encrypted column functionalities

In my current controller code, I am displaying a set of records. Here is the snippet: public function view() { $title = "View Guardian Information"; $vPa = DB::table('dbo_guardianinformation') ->join('dbo_cities ...

Having trouble with unexpected ternary statements appearing in Laravel Blade?

In one of my blade templates, I have a function call that should receive a string as its first parameter. However, Laravel seems to be interpreting the string and adding a ternary operation because it detects a '?' symbol followed by 'or'. Here's the issu ...

Using Laravel to set cookies with Ajax

I am facing difficulties in setting cookies through laravel using ajax. Despite reading several questions and posts, I have not been able to find a solution. My issue involves a dropdown that triggers a javascript function to send its value to a controlle ...

The specified route [Controller@method] does not exist

I'm currently working on creating a form that will interact with a controller method to insert new data into the database. I am using Laravel Version 4.1 app/views/projects.blade.php <tr> {{Form::open(array('action' => 'Pr ...

How to Handle Laravel Routing with URL Query Parameters

I am working on a route called stats. This is how my current routing setup looks like: Route::get('stats', 'StatsController@index'); Route::get('stats/{query}', 'StatsController@store'); The main objective is to display stat data when someone visits the ...

Why is it that every time I attempt to download a PDF document in Laravel, it opens as a file filled with gibberish characters

I am working on implementing a code to download a PDF file in the Laravel framework. Controller Code: public function initiatePDFDownload($id){ $service = Service::find($id); $pathArray = explode('/', $service->PDFPath); ...

Developing Laravel Blade shortcuts similar to those found in Wordpress

I am currently facing a challenge with a mail template in Laravel blade that needs to be dynamic and saved in the database. Below is an example of the registration_complete.blade.php file: <html> <body> {{$dynamic_content ...

Determine unique dates from DateTime values in MySQL

I need to extract data from a database table that logs requests with an IP address column and a timestamp. My goal is to determine the number of days a specific IP address has made requests. I am currently using Laravel's query builder for this task. This ...

Generating well-structured JSON response to be utilized in highcharts alongside Laravel is crucial for efficient data

In one of my views, I have integrated a highcharts chart and I am trying to load the data via ajax from an API route that returns a JSON response. Here is the API route I created: Route::get('api/v1/data/{id}', function($id) { //Perform som ...

Exclusion of Controller Methods with Laravel 4 Routing Filters

Is there a more efficient way in Laravel 4 to exclude certain methods from the 'auth.sentry' filter in a controller? Route::get('student/login','StudentController@getLogin'); Route::post('student/login','StudentController@postLogin'); Route::get('stude ...

Working with JSON responses in Laravel 4 and Mandrill

Recently, I have been utilizing Laravel (4.2) and its inbuilt Mandrill driver to send emails. However, I am facing a challenge in capturing the response from Mandrill. Below is the code snippet I am using to dispatch the message: Mail::queue('emails ...

When using Laravel's Response::json, a cross-domain error may still occur in the browser despite setting the header to Access-Control-Allow-Origin

I am facing a perplexing Laravel 4 issue. I have set up two methods in the same controller, which is declared to be restful. The problem arises when the ajax request comes from a different domain. The first method does not work: public function getOwnlis ...

Tips for maintaining checkbox checked status through page reloads

Hello there! In my Laravel e-commerce store, I have a list of currency values displayed as checkboxes. When a checkbox is selected, the page reloads to update the currency value. However, the checkbox selection is lost after the page reloads. Any suggest ...

Access values from the view in Blade without passing them as parameters

Is there a way to retrieve a variable named "foo" from a Blade template and pass it to a static function defined within the same template? For instance, let's say we have: <div class="collumns large-8"> {{ Helpers::setLetters('variable_n ...

What is the best way to handle binary files (such as images or audio) when serving them from a RESTful API that was built using

Exploring the most effective way to deliver files or bundles of files via a RESTful API. Considering options: Base64_encode files and include in JSON response Provide file links within JSON response Priority: Private access for certain files requiring ...

Retrieving the JSON data from an API using Laravel

Currently, I am experimenting with APIs and my latest project involves utilizing the Google Directions API within my application. To handle this, I have created a form to collect user input and generate the necessary URI directly in the routes.php file: ...

Configuring Laravel to operate on a specific port number?

Currently, I am utilizing nodejs, expressjs, and socket.io to trigger events on my web app via a mobile phone connected to the nodejs server. Although the app is primarily built in JavaScript, I have opted to use laravel for data storage within a database ...

Symfony equivalent of Auth::attempt

Looking for a straightforward way to authenticate users in Symfony similar to Laravel's Auth::attempt(... method. My user entity already implements AdvancedUserInterface, and I've been reviewing the Symfony security documentation. I'm searc ...

Add a fresh text field with the click of a button and delete it with another button in Laravel 4

My form includes two fields: phone and email, as shown in the image below. By clicking on the plus button, I would like to add an additional text field to the form below the button. Similarly, by clicking on the minus button, I want to remove the text fie ...

What is the process for removing a view from the master layout?

In my Laravel 4 application, I have a master layout located at /views/layouts/main.blade.php. However, I want to exclude this master layout from a single view: /views/users/login.blade.php. The main layout is a fully featured bootstrap admin layout with m ...

The Laravel AJAX request is malfunctioning

My form uses AJAX with $.post for GET and POST requests. However, after submitting the form using $.post, my page refreshes and the validation alert in the controller does not work. The AJAX request in the controller is not functioning correctly. Form: ...

Sharing variables between controllers in LaravelPassing data between controllers in Laravel

Recently, I started learning Laravel and came across a scenario where I have two controllers: CartController with the function finalizeCart and PaymentController with the function postPayment. Now, I am trying to figure out how to transfer the variable " ...

Effortlessly retrieve related data when serializing in Laravel Eloquent using toArray and toJson

I have been using this method to automatically fetch user and replies when serializing my object to JSON. However, I am not sure if overriding the toArray method is the correct approach for this. What do you think? <?php class Post extends Eloquent ...

The Laravel model's attribute appears as empty in the JSON response

In my Laravel 4.2 project, I have a model with a 'status' attribute and declared an accessor to handle it: public function getStatusAttribute($status) { if (isset($this->expires_at) && strtotime(\Carbon\Carbon::now()) > ...

How can I send multiple arrays to Response::json in Laravel?

How can we return multiple arrays in JSON format? Suppose we have the following response using Laravel eloquent: $user= User::all(); $post= Post::all(); $comment= Comment:all(); Now, I would like to return a JSON response that includes this data: Respon ...

Class for Laravel Authentication

For Laravel's auth class to function properly, is it necessary to have a database? Does this apply even if the server itself already has its own authentication process in place? I'm interested in utilizing Laravel's Auth class methods to determine whether ...

Laravel 4 - Error: Uncaught TypeError - Unable to access property 'post' as it is undefined

Here is the script I am using: <script> function selectModSetProd(prodId,setId,objControl){ function ifOK(r){ objControl.style.background="'"+r.color+"'"; } function ifError(e){ alert('An error ...

"Blank Canvas: Exploring the Void in Laravel Blade Templates

This is the route that I am using Route::get('login', function(){ return View::make('admins.login'); }); In this code, I have created a admins/login.blade.php file to handle the login view. <!doctype html> <html> <head> <met ...

Create a dynamic sitemap for a Laravel website that includes variables in the slugs

My Laravel-based website features URLs like this- xyz.com/search/{id}/{name} These URLs have two variables, allowing for multiple variations such as: xyz.com/search/1/katy xyz.com/search/2/john With potentially thousands of such URLs, I need to creat ...

Using a jquery function within a Laravel view

I am trying to retrieve a selected item from a dropdown menu using jQuery and then redirect it to a controller function. This function will return some data to be displayed based on the selected item. I could really use some assistance with this. Here is m ...

Executing an Ajax request to trigger a method in a Laravel 4 controller

As I am not an expert in Ajax, I am seeking guidance to find information on a specific task. Despite searching extensively on Stack Overflow, I either don't comprehend the details or it's not what I need. Uncertain if my goal is feasible at all.. ...

Nested looping within a table structure

I had a Users table and a group table. When I load the group table, it loads the users which have the same group_id as the group table id. It works, but my issue is that the foreach loop was quite messy. The output ends up looking like this... However, I ...

How can Laravel 4's Eloquent be used to implement 'offset' instead of 'page' in the ->paginate() method?

Currently, I am in the process of transferring an existing REST API to Laravel 4.1, where the API relies on the offset querystring parameter to define the offset for the records. My aim is to utilize Eloquent's default paginate(), but it recognizes the pa ...