Search the Community
Showing results for tags 'laravel'.
-
Hey the community, I need you once again There's something I couldn't wrap my head around with my web server... First things first, I'm running a Lightsail instance with a Lamp package using bitnami. My title may seem a bit weird. To better understand it, here's what I'm aiming to do : A user reaches domain.fr/blog He's been internally redirected to blog.domain.fr The address bar is still showing domain.fr/blog That's something I was able to achieve by using this in the bitnami-ssl.conf under <VirtualHost default:443> ProxyPass /blog http://blog.domain.fr/ ProxyPassReverse /blog http://blog.domain.fr/ So when I go to domain.fr/blog I can see the blog I'm setting up ! Now I've created myself two problems : If I reach blog.domain.fr I can access all of the content. Therefore, I have 2 canonical URLs for the same content, which is really bad for SEO. I can't access domain.fr/blog/login for instance... So I'm asking you guys two questions : How to redirect properly blog.domain.fr to domain.fr/blog How to make it works properly i.e., /blog/login not showing 404 (blog.domain.fr/login is working) One more precision : the blog I'm setting up is running using Laravel and Jetstream Here's what I tried to do : I've added under the <Virtual Host *:443> for the blog vhost this line : RewriteEngine On RewriteRule ^ https://domain.fr/blog%{REQUEST_URI} [L,R=301] I end up with the error TOO_MANY_REDIRECTS on both blog.domain.fr and domain.fr/blog I'm not an Apache expert or whatsoever, please be kind ! Feel free to ask any questions if what I'm trying to achieve seems hard to understand
-
Hello, after watching LTT's stream today where Linus told to hop into the forum to ask questions about servers, I decided to give it a try. About me: I'm a Windows user, and I do have some technical knowledge. I don't know enough about Linux, but I did use Ubuntu (which is probably irrelevant). I have a few questions regarding my plan to make a DIY Server PC. I'm going to upgrade my PC and I'm gonna repurpose my current one as a server. Server's "would-be" Specs: - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz - 8GB DDR4 RAM - 3TB HDD Storage - Intel(R) HD Graphics 530 (No external GPU) My plan for the server's use cases are: - hosting a data website I have (currently hosted on my current PC, built on laravel, have own custom domain) - set up Jellyfin and Navidrome/Koel to stream media/music - use some other self-hosted apps like NextCloud and password manager Here are some questions I'm meaning to ask: How do I actually run the server without user intervention, or with any other peripherals not connected? Do I need a separate SSD to run the server? I heard USB flash sticks are enough! Is it reliable information? What are some OS options than I can use? (TrueNAS core, etc) Is TrueNAS like an OS? I don't need any NAS like storage with raid/parity, other than maybe a SMB network location share. Aka, backup not important as it's mostly for media files and everything on the website is already on GitHub. Does Docker goes inside TrueNAS? How can I update my Laravel files from GitHub automatically? I've watched some YouTube channels like NetworkChuck and Raid Owl, but I'm still not sure how I should proceed. Any links to channels, videos, documentations will be helpful. As this is a passion project I don't want to spend much on any other hardware/subscriptions other than those I already have. Also any other tips, suggestions or experiences are welcome. I might have more questions, but for now this is all. Thank you!
-
hi all, i have a problem that is when i tap the rfid card to the scanner the display on the arduino serial monitor ide Error on sending POST: -1, can you all help me? This is my code in arduino ide using esp8266 : #include <SPI.h> #include <MFRC522.h> #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #define SS_PIN D2 //--> SDA / SS is connected to pinout D2 #define RST_PIN D1 //--> RST is connected to pinout D1 MFRC522 mfrc522(SS_PIN, RST_PIN); const char* ssid = "My WiFi"; const char* password = "MyPassword"; String content; void setup() { Serial.begin(115200); SPI.begin(); mfrc522.PCD_Init(); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting.."); } Serial.println(""); Serial.print("Successfully connected to : "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); Serial.println("Please tag a card or keychain to see the UID !"); Serial.println(""); } void loop () { if (WiFi.status() == WL_CONNECTED) { if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } if ( ! mfrc522.PICC_ReadCardSerial()) { return; } Serial.println(); Serial.print("UID tag :"); content = ""; byte letter; for (byte i = 0; i <mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? "0" : ""); Serial.print(mfrc522.uid.uidByte[i], HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "")); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } content.toUpperCase(); Serial.println(); kirim(); } else { Serial.println("Error in WiFi connection"); } } void kirim() { HTTPClient http; //Declare object of class HTTPClient String ValueSend, postData; //Read Analog value of LDR ValueSend = String(content); //String to interger conversionapp //Post Data postData = "uid=" + ValueSend; http.begin("http://MyIP:8000/perpustakaan-smk-bhakti-anindya/routes/web.php/UIDresult"); //:80 is port laravel, UIDresult is the url I created to point to the controller http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header int httpCode = http.POST(postData); //Send the request String payload = http.getString(); //Get the response payload //Serial.println("uid=" + ValueSend); if (httpCode > 0) { Serial.println(payload); } else { Serial.print("Error on sending POST: "); Serial.println(httpCode); } delay(2000); http.end(); //Close connection } And this my controller laravel : <?php namespace App\Http\Controllers; use App\Models\UidEntry; use App\Http\Requests\StoreUidEntryRequest; use App\Http\Requests\UpdateUidEntryRequest; use Illuminate\Support\Facades\DB; class UidEntryController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return view('GetUID/datauid', [ "uidentry" => UidEntry::all() ]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('register/index'); } /** * Store a newly created resource in storage. * * @param \App\Http\Requests\StoreUidEntryRequest $request * @return \Illuminate\Http\Response */ public function store(StoreUidEntryRequest $request) { $uid = $request->post('uid'); $values = array("uid" => $uid); DB::table('uid_entries')->insert($values); // if (null !== $request->get('uid')) { // $uid = $request->get('uid'); // dd($uid); // $values = array('uid' => $uid); // $result = DB::table('uid_entries')->insert($values); // // return response($result); // } //validate form // $this->validate($request, [ // 'uid' => 'required' // ]); // //upload image // $entry = str($_POST['uid']); // $image = $request->$entry; // //create post // UidEntry::create([ // 'uid' => $image // ]); // $validatedData = $request->validate([ // 'uid' => 'required' // ]); // UidEntry::create($validatedData); } /** * Display the specified resource. * * @param \App\Models\UidEntry $uidEntry * @return \Illuminate\Http\Response */ public function show(UidEntry $uidEntry) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\UidEntry $uidEntry * @return \Illuminate\Http\Response */ public function edit(UidEntry $uidEntry) { // } /** * Update the specified resource in storage. * * @param \App\Http\Requests\UpdateUidEntryRequest $request * @param \App\Models\UidEntry $uidEntry * @return \Illuminate\Http\Response */ public function update(UpdateUidEntryRequest $request, UidEntry $uidEntry) { // } /** * Remove the specified resource from storage. * * @param \App\Models\UidEntry $uidEntry * @return \Illuminate\Http\Response */ public function destroy(UidEntry $uidEntry) { // } } and this is my model laravel : <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class UidEntry extends Model { use HasFactory; // protected $guarded = ['id']; protected $fillable = [ 'uid' ]; // bisa insert data di database tanpa colum updated_at public $timestamps = false; } and the last, this is route in web.php laravel : <?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\UidEntryController; /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ // Route::get('/', function () { // return view('welcome'); // }); Route::resource('UIDresult', UidEntryController::class); dfdf
-
Hello, title says it all. I have 2 tables in the database that are for one "element" so first is just pool names and status on them, the other tables are drives and what pools they belong too. I have made a visual element for how I want it to be, I just don't know how I can display more on one page. So how does one do this?
-
Hello, so I'm quite new to laravel and I have just made my page display stuff from the database. It's displaying all my server pool sizes in bytes, how can I reformat them? (when I used normal php I used a function I still have to take the value and format it) I have tryed to search how to use functions in views but people said thats not the way to do it. How do you do this?
-
Hello, I'm trying to add a birthday form to my register page and I want to do it in 3 parts (etc like facebook) So 1 select form for days, months and years. How do I get the data and store it as a normal date in the database?
-
So I'm really not good at front end, but I would like to create a nice page where I upload files with no page updates. (I have already done this with deleting files in a table). So my issue is that I think laravel is not getting any data at all. The form code is really long so I shortened it down to the inputs and selects as thats whats important (this form worked as is before this ajax so it's nothing wrong with it) I have removed urls but they do work. <form action="/" method="post" enctype="multipart/form-data" id="file-upload"> <input type="hidden" name="_token" value="csrftokengoeshere"> <input type="file" name="file" id="file-select"> <select id="categoryselector" class="form-control m-b div-toggle" name="iscategory" data-target="#categorys"> <option selected="" value="false">No</option> <option value="true" data-show="#program">Yes</option> </select> <input placeholder="Program name" name="name" class="typeahead_1 form-control"> <input placeholder="version" name="version" class="form-control"> <select id="scan" class="form-control m-b" name="scan"> <option selected="" value="false">No</option> <option value="true">Yes</option> </select> <button class="btn btn-white btn-block" id="upload-button">Upload</button> </form> $('#file-upload').submit(function(e) { e.preventDefault(); var $form = $(this); $form.find('input, select, button, textarea'); var serializedData = $form.serialize(); $.ajax({ url: '/', type: 'POST', data: $form, processData: false, contentType: false, success: function( msg ) { if ( msg.status === 'success' ) { Snackbar.show({ text: msg.msg, pos: 'top-right' }); } else { Snackbar.show({ text: 'Oops.. ' + msg.msg, textColor: '#ff0000', pos: 'top-right' }); } }, }); return false; }); Currently laravel says token mismatch, in chrome I see that request payload is [object Object] What do I do to fix this?
-
Hello, So when I call my models etc like $book = $books->where('name', 'somebook')->first(); echo $book->sales(); //returns all sales echo $book->sales->today(); //returns all sales today So this is something I could no. but here is the catch for me. how do I make the ->today(); work? Currently I have no idea how I can add more functions, "sub functions to the sales function". What am I looking for? I just need the name of this so I can learn how to do it.
-
Hello, I want to create a "enable and disable" function. I did create a form that submited the post "status" with enable or disable. This works but is it the way to go? I want to use this themes switch which is a checkbox to enable or disable. But then I'm in need of the form auto submitting each update and how I would create the backend to work with that (simple if this then code goes here). How would you go about this? I also wanna move over to ajax later as I think it's cool not to update the page. (should I go with Vue or just pure javascrupt?)
-
Like the title says, i have found a few solutions but am curious how you guys solve this. Need some search option where I can type multiple values in a field and search through multiple tables/columns
-
So i have a column called password_reset to check if the account is forced to reset a password. If its logged in I want it to force to change it so always redirect to some page. Thought i would do this with a middleware registered in Kernel.php protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \App\Http\Middleware\UserCheck::class, ]; Called it UserCheck for now. According to the comment this will be ran everytime a HTTP request is runned. This works but now the actual middleware. <?php namespace App\Http\Middleware; use Closure; use Auth; class UserCheck { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = Auth::user(); dd($user); return $next($request); } } This returns NULL every HTTP request while it should return the currently logged in user. Auth::check also does not work. I have manipulated Auth so that it logs in with ID and Password instead of Username or Email. Dont thing this has anything to do with it but still worth to mention. Any idea?
-
Hello. So I'm creating a page to display all the users, but I want a few things that I do not know how I would go by creating. I want to be able to search for users, use a filter and have paginations. I could not find something like this by googling so how would I go by doing this?
-
Not sure how to explain this but let me give it a shot. Keep in mind i want to achieve this in Laravel. What i've got now is the page that display the Item name. and a join to the Stock table so i can use anything in there related to the item too. Can't seem quickly to figure out how i make sure that it makes nicely a join from the "store_id" to the Stores Table. Trying to do this on a Laravel approved way Code now. web.php Route::get('/item/{name}', 'ItemController@show'); ItemController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Item; class ItemController extends Controller { public function show($name) { $item = Item::where('name', $name)->firstOrFail(); return view('item.show')->with('item', $item); } } show.blade.php {{$item->name}} @foreach ($item->getStock as $shop) {{$shop->in_stock}} @endforeach Item.php (Model) public function getItemStats() { return $this->hasMany('App\Stock'); } This works just fine but when i try to link "store_id" from the Stock table and the "id" from the Stores table. Im not sure about how to do that properly. What i thought... Stock.php public function getStat() { return $this->hasOne('App\Stores'); } show.blade.php {{$item->name}} @foreach ($item->getStock as $shop) <!-- I want here to list the shop name from the Stores table--> {{$shop->getStore->store_name}} <!-- Something like this--> {{$shop->in_stock}} @endforeach the thing is im getting a error page which makes sense, but im kind of stuck and wanted to make a quick post so i might fix this faster ErrorException (1/2) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stores.item_store_id' in 'where clause' ErrorException (2/2) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stores.item_store_id' in 'where clause' (SQL: select * from `stores` where `stores`.`item_store_id` is null and `stores`.`item_store_id` is not null limit 1) Im sure there is a way to set the column he is looking for (item_store_id) to just (id) But then he is looking for a value where NULL.
-
Hello, Been googling a bit but couldent find what I was looking for. I want to create custom validations for stuff I have, etc ranks or country. how do I do this? Best would be a link to how you do it if there is a official way.
-
How to choose a element from a formula in a dusk test
Janick.Spielmann posted a topic in Programming
I am working on a project for university here in Switzerland I have already tried reading the laravel dusk instruction (https://laravel.com/docs/5.8/dusk) and googled it. But I could not finde anything that works. so here is my problem. I have a filter with witch I can choose a type (Typ) and a manufacturer (Hersteller) from a list. and I tried ->type and then ->click a item but that dose not work ? How can I choose a item from the list? -
Hi I want to open an existing Laravel project. The Project comes with a MySQL database. I am using Ubuntu 18.04 and I have managed to set up Xampp. I can now see the phpMyAdmin page if I visit localhost/phpmyadmin/ The project file and database are located at /home/USERNAME/projects/PROJECTNAME do I have to move the projects to a curtain folder or can I somehow make Xampp load this folder? I will be using Phpstorm and Datagrip to work on the project. I hope someone knows his/her way around Xampp. I somewhat know what I am doing but it's my first time setting this up so sometimes simple stuff is the hardest because there is no documentation. Thanks for helping Janick
-
foreach ($value->service as $service) { if (in_array($service, $request->service)) { $ok = true; } } "Undefined property: stdClass::$service" line 254 (the foreach line) foreach ($value->service as $service) { echo $service; } die(); "service1service2service3service4" foreach ($value->service as $service) { echo gettype($service); } die(); "stringstringstringstring" What's going on here? ($value->service is a collection and $request->service is a array) I have literary no clue whats going on here, I'd love if someone spots what I'm doing wrong.
-
I feel like this is a really basic thing but yet I have to ask with limited knowledge on Javascript/Vue I have a form where you can add dynamic fields with Vue.js and it submits just fine, makes a nice array validations goes great and all. But now when something goes wrong, and not specially in that field there is a bit of an issue in my mind with putting the "old" data back by the old() function. Let me first start with showing you what I got. create.blade.php <div class="col-md-6"> <div class="section"> <label for="age">Password</label> <a v-on:click="addPasswordField"> <span class="panel-title glyphicon glyphicon-plus" aria-hidden="true"></span> </a> <a v-on:click="deletePasswordField" v-if="password_fields.length > 0"> <span class="panel-title glyphicon glyphicon-remove" aria-hidden="true"></span> </a> <div class="password row" v-for="(field, index) in password_fields"> <input type="text" class="form-control" :name="'task[passwords][' + index + '][password]'" v-bind:value='field.password'> <input type="text" class="form-control" :name="'task[passwords][' + index + '][description]'" v-bind:value='field.description'> <input type="text" class="form-control" :name="'task[passwords][' + index + '][login]'" v-bind:value='field.login'> </div> </div> </div> App.js var createTask = new Vue({ el: '#createTask', data: { password_fields: [], }, methods: { addPasswordField() { this.password_fields.push({ password: '', description: '', login: '' }) }, deletePasswordField(index) { this.password_fields.splice(index,1) }, }, }); Now for every add it just adds empty fields. Now my goal is when there is old data to pass it to vue, so I can make a method what fills the "password_fields" array with the old data. Perhaps you guys can help me find a clean way.
-
First of all i'm going to abuse my knowledge to tag @leodaniel since he manage to answer most of the Laravel questions here. My Goal : I have one pretty big forum, where you can fill in a Customer with their phone number and then a Task (Task can be a broken phone which we have to fix, so their reason of visit) In that task we save passwords and additional items they have given us (charges, sd-cards) Migrations : Schema::create('customers', function (Blueprint $table) { $table->increments('id'); $table->string('first_name')->nullable(); $table->string('last_name'); $table->timestamps(); }); Schema::create('customers_phone_numbers', function (Blueprint $table) { $table->increments('id'); $table->integer('cid')->unsigned()->comment('Refers to ID in customers'); $table->string('number', 10); $table->string('description'); $table->timestamps(); }); Schema::create('tasks', function (Blueprint $table) { $table->increments('id'); $table->string('code', 8)->unique(); $table->integer('cid')->unsigned()->comment('Refers to ID in customers'); $table->string('type'); $table->string('brand'); $table->string('color'); $table->integer('age'); $table->text('description'); $table->timestamps(); }); Schema::create('tasks_additionals', function (Blueprint $table) { $table->increments('id'); $table->integer('tid')->unsigned()->comment('Refers to ID in tasks'); $table->string('description'); $table->timestamps(); }); Schema::create('tasks_passwords', function (Blueprint $table) { $table->increments('id'); $table->integer('tid')->unsigned()->comment('Refers to ID in tasks'); $table->string('description'); $table->string('password'); $table->timestamps(); }); Now i've created in the HTML arrays of the stuff so example : <!-- customer stuff --> <input id="" type="text" class="form-control" name="customer[first_name]"> <input id="" type="text" class="form-control" name="customer[last_name]"> <input id="" type="text" class="form-control" name="customer[phone_numbers][number]"> <!-- This is a other relation (table : customer_phone_numbers) --> <!-- Task stuff --> <input id="" type="text" class="form-control" name="task[brand]"> <input id="" type="text" class="form-control" name="task[type]"> <input id="" type="text" class="form-control" name="task[color]"> <input id="" type="text" class="form-control" name="task[additionals][description]"> <!-- This is a other relation (table : task_additionals) --> <!-- The following holds an other problem --> <input id="" type="text" class="form-control" name="task[passwords][password]"> <!-- This is a other relation (table : task_passwords) --> <input id="" type="text" class="form-control" name="task[passwords][description]"> <!-- This is a other relation (table : task_passwords) --> To be clear this is all 1 form and goes to the same POST url I'm kind of struggling to explain this I'm trying to find a solution to solve this or a best practice on how to create this with being laravel friendly, i'm struggling with the following points. Validation checks ((for every relation) Aborting customer creation when a phone_number validation fails. Brain capacity (other subject) I leave it at this, need to pick someone's brain about this.
-
Hello, How can I create dynamically emails from normal html + css stylesheets? Since most email services don't allow external stuff like css (In my experience). I could always create the email template with inline css, but that takes a lot of time since I'm basing it of a theme, if I where to change stuff I'd have to do it over again. What I do now is create the template I want and run it thru some service that takes the css stylesheets and the html and creates a inline style html file back.
-
Hey, I'm making an Web based application for a sound&light company wich need to automaticly make invoices and offers for customers. I'm using the laravel framework. So in the app we can make packs of items. for example: Costumers can choose an pre made pack. Simple Party Setup: Led Devil II (x1) Ledcon-02 (x1) Lightbar Led 4TC (x1) Mackie SRM-450 (top) (x2) Pioneer CDJ-2000nexus (x2) Pioneer DJM-900 nexus (x1) So to make this pack laravel proviodes nice ways to handle the pivot tables and relations (Eloquent) but i'm a bit stuck on the UI side the creqtion of packs. i want to use a multiselect to Select the multiple items i want to be in the pack i wanna make but i also want to directly add the quantity of items. Something like this (sorry for the paint skills) : I already searched around for simular multiselect boxes but i didn't found one with the option to input something allong with your selection. Is this possible in a way or in a simular option. or does anyone have a different approach in laravel ? Also i have some questions on the server side how i gonna handle that in the request. I hope one of you guys know a solution to my issue
-
So I always have the LTT forum open in a tab or two, and I was browsing Laracasts.com to brush up on my PHP/Laravel skills while in work, and I noticed the Favicon's were close to identical. At first I though my Safari was just putting the LTT favicon.ico on Laracasts, but no, they just coincidently appear to be very similar. Just though I'd point that out. Also if there are any other Laravel debs out there, Hi!
-
Hi there, It's been a while since I was on here... So, my team has to build a working site in 72 hours (short time, right?) using Laravel. So far, we have the UI ready (thanks to Materialize) and have no problems with making them... he main problem is that due to the lack of time, we were not taught how to perform sql queries properly with laravel... the laracasts and documentation aren't helping too much either... pls halp... -Hermit P.S. To those who wonder why I was off for a really long time, it's because of a lot of stuff going on IRL... Like this one right here...
-
I'm trying to create an employee profiling system and I'm looking for the best free admin panel. Also, a package that easily to customize its interface.