Sergiu17

Experience

150,510

50 Best Reply Awards

  • Member Since 1 Year Ago
  • 1155 Lessons Completed
  • 11 Favorites

22nd July, 2018

Sergiu17 left a reply on Error Installing Laravel 5.6 App On Remote Hosting • 15 hours ago

Try /var/log/apache/access.log or /var/log/apache2/access.log or /var/log/httpd/access.log. This are apache logs, see what's there!

21st July, 2018

Sergiu17 left a reply on Best Design Tool For Front-end • 1 day ago

Hello, I know about https://webflow.com/

20th July, 2018

Sergiu17 left a reply on Laravel 5.6 "Page Not Found" Problem • 2 days ago

php artisan route:list

Show your entire routes.php file.

Sergiu17 left a reply on Log All Queries To Database • 2 days ago

DB::listen(function ($query) {
    // $query->sql
    // $query->bindings
    // $query->time
});

from documentation https://laravel.com/docs/5.6/database#listening-for-query-events

19th July, 2018

Sergiu17 left a reply on How To Make "global" Function ? • 3 days ago

app/Helpers/helpers.php

// composer.json

'files': [
        'app/Helpers/helpers.php',
]

next, run composer dump-autoload or composer du

Sergiu17 left a reply on Mass Updates Without Touching Timestamps • 3 days ago

Ohh, sorry, I did copy-paste, as @Cronix said App::withoutTimestamps() :)

Sergiu17 left a reply on (1/1) MethodNotAllowedHttpException • 3 days ago

php artisan route:list

make sure you send request to /check-token-view// slash in front, post method

Sergiu17 left a reply on Mass Updates Without Touching Timestamps • 3 days ago

Not sure, I didn't test this, but give a try

class App extends Model
{
    public function scopeWithoutTimestamps()
    {
        $this->timestamps = false;
        return $this;
    }
}

App::scopeWithoutTimestamps()->select() // ...

Maybe it will work

Sergiu17 left a reply on (1/1) MethodNotAllowedHttpException • 3 days ago

Route::post('/check-token-view', '[email protected]_tokens_data');

Make sure your form sends a POST request to this end point

<form method='post' action='/check-token-view'>
    @csrf
</form>

Sergiu17 left a reply on How To Make A Href With Url And Var • 3 days ago

 <a href="https://waze.com/ul?ll={{ $business->latitude  }},{{ $business->longitude }}&navigate=yes" class="btn btn-icon btn-primary">

Sergiu17 left a reply on Middleware Throttle For Single Request • 3 days ago

Inside app/Http/Kernel.php in $middlewareGroups you could define your own group

protected $middlewareGroups = [
    'customApi' => [
        'throttle',
        'api.auth'
    }
];
Route::group(['middleware' => ['customApi']], function () {
    Route::get('api/test.json', '[email protected]');
});

Hope this will finally work

Sergiu17 left a reply on (1/1) MethodNotAllowedHttpException • 3 days ago

When you submit your form, don't forget about csrf

<form>
{{ csrf_field() }}
</form>

or if you user 5.6+

<form>
@csrf
</form>

Sergiu17 left a reply on Middleware Throttle For Single Request • 3 days ago

Route::group(['middleware' => ['api.auth', 'throttle:2,1']], function () {
    //
});

like so i guess :)

Sergiu17 left a reply on Middleware Throttle For Single Request • 3 days ago

'middleware' => 'throttle'

Sergiu17 left a reply on Installing Horizon Problem 1 • 3 days ago

Open terminal

php -ini | grep pcntl

if is disabled - enable it, or install it, to install google for install pcntl extension mac

Sergiu17 left a reply on Make A Migration One Way • 3 days ago

@Phill93 inside up() and down() you could write whatever you want, you can select all data and save into another table, you could create others tmp tables where you can store your data

public function up()
{
    $data = DB('table')->get();
    foreach($data as $item)
    {
        // insert into other table
    }

    // here goes your schema table
}

18th July, 2018

Sergiu17 left a reply on Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException • 4 days ago

Route::post('/store','[email protected]');

<form action="/store" method="post">
@csrf
</form>

If you follow the convention of the Laravel, create route is to show the form to create Ticket in your case, and store method is to store (save, persist) record into database, make sure you send a post request and you include csrf.

Sergiu17 left a reply on How To Structure My Laravel Project • 4 days ago

process/transform => `app/Services/Transformer.php

the DB query code => app/Repositores/ModelRepository.php

controller => app/Http/Controllers/APIs/MainController.php

this how I'd do

Sergiu17 left a reply on Passing Variables To JS • 4 days ago

Use ajax request, return json from your controller and make a request to the end point

https://github.com/axios/axios this one seems to be very common

Sergiu17 left a reply on Help To Seperate Backend And Frontend In Laravel • 4 days ago

@techyad you mentioned about Yii2, as I see, you have to create 2 laravel applications, one for frontend and one for backend

cd /your-project
composer create-project --prefer-dist laravel/laravel backend
composer create-project --prefer-dist laravel/laravel frontend

17th July, 2018

Sergiu17 left a reply on Help To Seperate Backend And Frontend In Laravel • 5 days ago

The cooler way is you create BackEnd with Laravel and provide APIs for the FrontEnd created by Vue or Angular or React.

Or you could just create FrontEnd and BackEnd folders inside Http/Controller, resources/view and so one, to separate things

16th July, 2018

Sergiu17 left a reply on How To Show And Hide Content Using Select Dropdown Box With Jquery • 6 days ago

@icelander show your html code, show you controller and format your code with 3 back ticks ``` before and after the code

Sergiu17 left a reply on Tinker Won't Detect Migration Class • 6 days ago

@AlexanderKim try to use composer autoload

Sergiu17 left a reply on Tinker Won't Detect Migration Class • 6 days ago

Migration files don't have namespaces, and even worst they aren't autoloaded

Sergiu17 left a reply on Company Intranet Using Laravel - Do I Don't I??? • 6 days ago

how you go about taking a site developed locally on my Macbook and publish to a Windows Server environment that runs XAMPP

Upload project to github, ssh to your server, run git clone, then composer install --dev - live. done.

Sergiu17 left a reply on How To Send Data To An External URL As A POST Method • 6 days ago

Open Developer tools -> Network tab and you will see 'their URL'

Sergiu17 left a reply on Insert Post From Another Website To My DataBase • 6 days ago

No. You could use APIs ( if they provide ).

Sergiu17 left a reply on How To Show And Hide Content Using Select Dropdown Box With Jquery • 6 days ago

You have to wrap your JS code into an event.

$('#select-input').on('change', function() {
    var select_status = $('#categorys').val(); 
    if( select_status == {{ $sel->id }} ) {
        $('#problems').show(); 
    } else { 
        $('#problems').hide();
    }
});

How every time you change option, the code inside the event will run

Sergiu17 left a reply on My Laravel Project Won't Work In Plesk • 6 days ago

I think that the problem is in PHP version, Laravel 5.6 requires PHP >= 7.1.3

15th July, 2018

Sergiu17 left a reply on Can't Connect To Local MySQL Server Through Socket '/tmp/mysql.sock' (2) • 1 week ago

Are you connecting to "localhost" or "127.0.0.1" ? I noticed that when you connect to "localhost" the socket connector is used, but when you connect to "127.0.0.1" the TCP/IP connector is used. You could try using "127.0.0.1" if the socket connector is not enabled/working.

From StackOverflow

12th July, 2018

Sergiu17 left a reply on Unique Email Validation On Update (Laravel 5.6) • 1 week ago

Google for laracasts update unique email

'email' => 'required|email|unuque:businesses,email, '. auth()->user()->id . ',id'

And Jeffrey has an video tutorial about this problem

11th July, 2018

Sergiu17 left a reply on Runtime Form Variable/row Addition • 1 week ago

You create separate table, which will contain id, user_id, school_name.

<input type='text' name='schools[]'> // <--- it's important to add [ ]
<input type='text' name='schools[]'>

Now, no matter how many education schools user adds, you will get an array of schools.

public function store(Request $request)
{
    dd($request->schools); // dumps an array of schools.

    // next you save them to database, and assign user_id
    foreach($request->schools as $school)
    {
        $school = new School();
        $school->user_id = $user_id;
        $school->school_name = $school;
        $school->save();
    } 
}

That's probably it)

Sergiu17 left a reply on Tailwindcss Mobile First • 1 week ago

@Swaz Thanks!

Sergiu17 left a reply on How Call A Middleware Out Of Controller's Constructor? • 1 week ago

Route::group(['middleware' => 'your-middle-ware'], function()
{
    Route::resource('/resource-name', 'YourControllerWithFiveMethods');
});

Sergiu17 left a reply on Update Status Dots After Successfully Executing Function In Controller • 1 week ago

@if($message = Session::get('message'))

And

@if($message == Session::get('message'))

Feel the difference ? With = (one equal sight ) it will return true

Hope the problem is in this if statement

Sergiu17 left a reply on Tailwindcss Mobile First • 1 week ago

class='p-5 md:p-0 lg:p-0 xl:p-0

I'm writing from phone. Can't edit previous post. This is what you need

Sergiu17 left a reply on Tailwindcss Mobile First • 1 week ago

By default you want 5px padding, on md, lg and xl you want 0px, so you apply 0px

class='p-5 md:p-5 lg:p-5 xl:p-5'

Sergiu17 left a reply on How To Get Users Friend Birthdays List • 1 week ago

You should have a relationship on user model called friends next

$myFriends = auth()->user()->friends;
foreach($myFriends as $friend)
{
    // print birthday's friend
}

10th July, 2018

Sergiu17 left a reply on Errore In "php Artisan Migrate" And Trouble With Mysql 8 And Laravel On Mac • 1 week ago

If you can, switch to Docker, no more PHP install, or Server, or Mysql, or Redis, ElasticSearch, whatever.. just add new container in docker and run a simple command to start the container. https://phpdocker.io/generator here you could generate docker-compose.yml file for your application

Sergiu17 left a reply on How To Not Allow A Conditional Id To Pass Through Route • 1 week ago

Route::get('post/{post}', '[email protected]');

public function display(Post $post)
{
    if($post->lang == 0)
    {
        abort(404, 'Not found!');
    }
}

I changed 'post/{id}' to 'post/{post}', you could keep 'post/{id}'

public function display(Post $id)
{
    if($id->lang == 0)
    {
        abort(404, 'Not found!');
    }
}

9th July, 2018

Sergiu17 left a reply on Laravel Auth With Custom Error Messages • 1 week ago

Yes, you could do something like this

$validator = Validator::make($request->all(), [
    'title' => 'required|unique:posts|max:255',
    'body' => 'required',
]);

if ($validator->fails()) {
    return redirect('post/create')
    ->withError('My error message');
}

https://laravel.com/docs/5.6/validation

Sergiu17 left a reply on Laravel Auth With Custom Error Messages • 1 week ago

@johnk create a folder resources/lang/de/auth.php

<?php

return [
    'failed' => 'Failed message in DE',

And make sure that in config file config/app.php you set your locale to de

'locale' => 'de',

Sergiu17 left a reply on The File "C:\xampp\tmp\php8911.tmp" Does Not Exist • 1 week ago

First, solution is to try to read message till end.

$file = $file->move(public_path($imagePath) , $filename);

dd($file); // DO YOU GET SOMETHING HERE?

Sergiu17 left a reply on Laravel Auth With Custom Error Messages • 1 week ago

resources/lang/en/auth.php ?

Sergiu17 left a reply on The File "C:\xampp\tmp\php8911.tmp" Does Not Exist • 1 week ago

dd($file); // dumps the file, it exists.

$file = $file->move(public_path($imagePath) , $filename);

dd($file); // It can't find the file anymore, because it's moved to $imagePath

$sizes = ["300" , "600" , "900"];

$url['images'] = $this->resize($file->getRealPath() , $sizes , $imagePath , $filename);

$file->getRealPath() // won't work

Hope that this is the problem...yesterday I had similar problem :)

Sergiu17 left a reply on Cleaning Up Image Storing Method • 1 week ago

public function upload($file)
{
    $fileName = // ...
    $thumbName = // ...

    return [$fileName, $thumbName];
}
public function store(Request $request, File $file)
{
    $names = $file->upload($request->file('image'));
    $post->cover_image = $names[0];
    $post->thumb_image = $names[1];
}
    

One way to do this

8th July, 2018

Sergiu17 left a reply on Insert A Array To Array • 2 weeks ago

If I understood correctly

$array = ['one', 'two', 'three'];
    
$products = [
    ['name' => 'Apple', 'price' => '1000', 'color' => 'red'],
    ['name' => 'Google', 'price' => '1000', 'color' => 'green'],
    ['name' => 'Samsung', 'price' => '1000', 'color' => 'blue'],
];

foreach ($products as $product)
{
    array_unshift($array, $product);
}

dd($array);

array:6 [▼
  0 => array:3 [▼
    "name" => "Samsung"
    "price" => "1000"
    "color" => "blue"
  ]
  1 => array:3 [▼
    "name" => "Google"
    "price" => "1000"
    "color" => "green"
  ]
  2 => array:3 [▼
    "name" => "Apple"
    "price" => "1000"
    "color" => "red"
  ]
  3 => "one"
  4 => "two"
  5 => "three"
]

If I didn't understand correctly, show your products array and describe the result you want!

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.